racket/gui win32: fix Space handling of buttons and checkboxes

Suppress WM_KEYDOWN messages to a button or checkbox, so that the
top-level window takes care of Space and Return for a button or
checkbox with the keyboard focus.

Closes PR 14710

original commit: 032397d6f9694d4c3dff24e3511d51657d19cf15
This commit is contained in:
Matthew Flatt 2014-08-31 03:56:49 -06:00
parent 4a497f5be3
commit 3dcb02a3fc
2 changed files with 18 additions and 8 deletions

View File

@ -154,6 +154,13 @@
xp-label-font))))
(super set-label s)))
;; Avoid passing any key event to a button or checkbox. The
;; `pre-on-char` of the frame will take care of changing space to
;; a control action, but the control itself may use WM_KEYDOWN
;; instead of WM_CHAR.
(define/override (capture-all-key-events?)
#t)
(define/override (is-command? cmd)
(= cmd BN_CLICKED))

View File

@ -549,14 +549,15 @@
(define/private (do-key w msg wParam lParam is-char? is-up? default)
(let ([e (maybe-make-key-event #f wParam lParam is-char? is-up? hwnd)])
(if (and e
(if (definitely-wants-event? w msg wParam e)
(begin
(queue-window-event this (lambda () (dispatch-on-char/sync e)))
#t)
(constrained-reply eventspace
(lambda () (dispatch-on-char e #t))
#t)))
(if (or (and e
(if (definitely-wants-event? w msg wParam e)
(begin
(queue-window-event this (lambda () (dispatch-on-char/sync e)))
#t)
(constrained-reply eventspace
(lambda () (dispatch-on-char e #t))
#t)))
(capture-all-key-events?))
0
(default w msg wParam lParam))))
@ -740,6 +741,8 @@
(define/public (definitely-wants-event? w msg wParam e)
#f)
(define/public (capture-all-key-events?)
#f)
(define/public (dispatch-on-char/sync e)
(pre-event-refresh #t)