fix bugs in support and docs for the snip flag HANDLES-BETWEEN-EVENTS

(the previous commit was pushed too soon; it is completely broken. Apologies)
This commit is contained in:
Robby Findler 2015-12-17 16:16:40 -06:00
parent 759d89443f
commit 3af5db35be
2 changed files with 14 additions and 17 deletions

View File

@ -312,11 +312,11 @@ following symbols:
not have the keyboard focus (see also
@method[snip% on-goodbye-event])}
@item{@indexed-racket['handles-between-events] --- this snip wishes
to handle mouse events that are between items in the snip
@item{@indexed-racket['handles-between-events] --- this snip handles
mouse events that are between items in the snip
(instead of defaulting to treating mouse clicks as
setting the position or other event handling that happens
at the @racket[text%] or @racket[pasteboard%] level}
at the @racket[text%] or @racket[pasteboard%] level)}
@item{@indexed-racket['width-depends-on-x] --- this snip's display
width depends on the snip's x-@techlink{location} within the

View File

@ -464,19 +464,16 @@
;; FIXME: old code returned if !dc
(values dc (+ x scrollx) (+ y scrolly) scrollx scrolly)))])
(let ([snip
(let-boxes ([onit? #f]
[how-close 0.0]
(let-boxes ([how-close 0.0]
[now 0])
(set-box! now (find-position x y #f onit? how-close))
;; FIXME: the following refinement of `onit?' seems pointless
(let ([onit? (and onit?
(or (and (not (zero? how-close))
((abs how-close) . > . between-threshold))
(has-flag? (snip->flags s-caret-snip)
HANDLES-BETWEEN-EVENTS)))])
(if onit?
;; we're in the snip's horizontal region...
(let ([snip (do-find-snip now 'after)])
(set-box! now (find-position x y #f #f how-close))
(let* ([snip (do-find-snip now 'after)]
[onit? (or (and (not (zero? how-close))
((abs how-close) . > . between-threshold))
(has-flag? (snip->flags snip)
HANDLES-BETWEEN-EVENTS))])
(if onit?
;; we're in the snip's horizontal region...
;; ... but maybe the mouse is above or below it.
(let-boxes ([top 0.0]
[bottom 0.0]
@ -486,8 +483,8 @@
(get-snip-location snip dummy bottom #t))
(if (or (top . > . y) (y . > . bottom))
#f
snip)))
#f)))])
snip))
#f)))])
(when (send event button-down?)
(set-caret-owner snip))
(when (and prev-mouse-snip