From 3af5db35be44001e3533e7ddac6ecc8e018dc087 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Thu, 17 Dec 2015 16:16:40 -0600 Subject: [PATCH] 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) --- gui-doc/scribblings/gui/snip-class.scrbl | 6 +++--- gui-lib/mred/private/wxme/text.rkt | 25 +++++++++++------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/gui-doc/scribblings/gui/snip-class.scrbl b/gui-doc/scribblings/gui/snip-class.scrbl index 763a4553..f0dadaf0 100644 --- a/gui-doc/scribblings/gui/snip-class.scrbl +++ b/gui-doc/scribblings/gui/snip-class.scrbl @@ -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 diff --git a/gui-lib/mred/private/wxme/text.rkt b/gui-lib/mred/private/wxme/text.rkt index ce026f57..5fc6b885 100644 --- a/gui-lib/mred/private/wxme/text.rkt +++ b/gui-lib/mred/private/wxme/text.rkt @@ -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