fix for `get-current-mouse-state' on Mac OS X 10.5 and earlier

It looks like button-press information is not available on 10.5
and earlier, so so try to report it in that case.

Closes PR 13780

original commit: d695e8a15afff1da7c3306a717ef7d102483873f
This commit is contained in:
Matthew Flatt 2013-07-14 17:11:20 -06:00
parent e10ab086ee
commit 858a890046
2 changed files with 10 additions and 4 deletions

View File

@ -198,9 +198,13 @@ break is sent (via @racket[break-thread]) to the created eventspace's
(listof (or/c 'left 'middle 'right
'shift 'control 'alt 'meta 'caps)))]{
Returns the current location of the mouse in screen coordinates,
and returns a list of symbols for mouse buttons and modifier keys
that are currently pressed.}
@margin-note{On Mac OS X 10.5 and earlier, mouse-button information is
not available, so the second result includes only symbols for modifier
keys.}
Returns the current location of the mouse in screen coordinates, and
returns a list of symbols for mouse buttons and modifier keys that are
currently pressed.}
@defproc[(hide-cursor-until-moved) void?]{

View File

@ -200,7 +200,9 @@
(define (get-current-mouse-state)
(define posn (tell #:type _NSPoint NSEvent mouseLocation))
(define buttons (tell #:type _NSUInteger NSEvent pressedMouseButtons))
(define buttons (if (version-10.6-or-later?)
(tell #:type _NSUInteger NSEvent pressedMouseButtons)
0))
(define mods (tell #:type _NSUInteger NSEvent modifierFlags))
(define (maybe v mask sym)
(if (zero? (bitwise-and v mask))