From f93ff4de26248f6d3b2fd96c4a9da0c470c1494e Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Sun, 26 Jun 2011 15:47:16 +0800 Subject: [PATCH] added get-pos/text-dc-location method to editor:basic in framework --- collects/framework/private/editor.rkt | 7 ++++--- collects/scribblings/framework/editor.scrbl | 9 ++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/collects/framework/private/editor.rkt b/collects/framework/private/editor.rkt index c2de47acd5..42c8e04397 100644 --- a/collects/framework/private/editor.rkt +++ b/collects/framework/private/editor.rkt @@ -52,9 +52,10 @@ #f)) (define/public (get-pos/text event) - (let ([event-x (send event get-x)] - [event-y (send event get-y)] - [on-it? (box #f)]) + (get-pos/text-dc-location (send event get-x) (send event get-y))) + + (define/public (get-pos/text-dc-location event-x event-y) + (let ([on-it? (box #f)]) (let loop ([editor this]) (let-values ([(x y) (send editor dc-location-to-editor-location event-x event-y)]) (cond diff --git a/collects/scribblings/framework/editor.scrbl b/collects/scribblings/framework/editor.scrbl index 0eecdae442..87ba2c97ab 100644 --- a/collects/scribblings/framework/editor.scrbl +++ b/collects/scribblings/framework/editor.scrbl @@ -124,6 +124,13 @@ (values (or/c false/c number?) (or/c false/c (is-a?/c editor<%>)))]{ + Calls @method[editor:basic<%> get-pos/text-dc-location] with + the x and y coordinates of @racket[event]. + } + @defmethod[(get-pos/text-dc-location [x exact-integer?] [y exact-integer?]) + (values (or/c false/c number?) + (or/c false/c (is-a?/c editor<%>)))]{ + This method's first result is @racket[#f] when the mouse event does not correspond to a location in the editor. @@ -132,7 +139,7 @@ otherwise the first result will be @racket[#f]. The @racket[editor<%>] object will always be the nearest - enclosing editor containing the mouse click. + enclosing editor containing the point (@racket[x], @racket[y]). } } @defmixin[editor:basic-mixin (editor<%>) (editor:basic<%>)]{