From 030a02a53c285423ef61309de6c631a7325a896e Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sat, 16 May 2015 09:05:22 -0600 Subject: [PATCH] add `{get,set}-area-selctable` to `pasetboard%` --- .../scribblings/gui/pasteboard-class.scrbl | 20 +++++++++++++++++++ gui-lib/info.rkt | 2 +- gui-lib/mred/private/wxme/pasteboard.rkt | 9 ++++++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/gui-doc/scribblings/gui/pasteboard-class.scrbl b/gui-doc/scribblings/gui/pasteboard-class.scrbl index 53b59c65..e4656dbb 100644 --- a/gui-doc/scribblings/gui/pasteboard-class.scrbl +++ b/gui-doc/scribblings/gui/pasteboard-class.scrbl @@ -612,6 +612,16 @@ The @racket[x] and @racket[y] arguments are in editor coordinates. If } +@defmethod[(get-area-selectable) + boolean?]{ + +Returns whether snips can be selected by dragging a selection box in the + pasteboard's background. By default, area selection + is allowed. See also @method[pasteboard% set-area-selectable]. + +@history[#:added "1.12"]} + + @defmethod[(get-center) (values real? real?)]{ Returns the center of the pasteboard in pasteboard coordinates. @@ -1111,6 +1121,16 @@ See also @method[pasteboard% raise], @method[pasteboard% lower], and } +@defmethod[(set-area-selectable [allow-drag? any/c]) + void?]{ + +Set whether snips can be selected by dragging a selection box in the + pasteboard's background by event handling in @method[pasteboard% + on-default-event]: a true value allows selection, @racket[#f] + disallows selection. See also @method[pasteboard% get-area-selectable]. + +@history[#:added "1.12"]} + @defmethod[(set-before [snip (is-a?/c snip%)] [before (or/c (is-a?/c snip%) #f)]) diff --git a/gui-lib/info.rkt b/gui-lib/info.rkt index 3a2b76c7..2a84ac9e 100644 --- a/gui-lib/info.rkt +++ b/gui-lib/info.rkt @@ -30,4 +30,4 @@ (define pkg-authors '(mflatt robby)) -(define version "1.11") +(define version "1.12") diff --git a/gui-lib/mred/private/wxme/pasteboard.rkt b/gui-lib/mred/private/wxme/pasteboard.rkt index 022ade20..b1fa0408 100644 --- a/gui-lib/mred/private/wxme/pasteboard.rkt +++ b/gui-lib/mred/private/wxme/pasteboard.rkt @@ -132,6 +132,7 @@ (define keep-size? #f) (define dragging? #f) (define rubberband? #f) + (define can-rubberband? #t) (define rb-x 0.0) (define rb-y 0.0) @@ -369,7 +370,8 @@ (unless (send event get-shift-down) (no-selected)) (set-caret-owner #f) - (set! rubberband? #t))) + (when can-rubberband? + (set! rubberband? #t)))) (set! start-x x) (set! last-x x) (set! start-y y) @@ -2041,6 +2043,11 @@ (def/public (set-selection-visible [bool? v]) (set! selection-visible? v)) + (def/public (get-area-selectable) can-rubberband?) + + (def/public (set-area-selectable [bool? d?]) + (set! can-rubberband? d?)) + ;; ---------------------------------------- (def/public (can-insert? [snip% a] [(make-or-false snip%) b] [real? x] [real? y])