cocoa: avoid infinite loop on re-dispatch of command keys

This commit is contained in:
Matthew Flatt 2010-11-30 20:17:47 -07:00
parent d95e6f35c1
commit e627ccb5ed

View File

@ -35,6 +35,7 @@
"MrEd"))
(define the-apple-menu #f)
(define recurring-for-command (make-parameter #f))
(define-objc-class MyBarMenu NSMenu
[]
@ -44,13 +45,16 @@
(or (and the-apple-menu
(tell #:type _BOOL the-apple-menu performKeyEquivalent: evt))
;; Explicity send the event to the keyWindow:
(and
(not (recurring-for-command))
(let ([w (tell app keyWindow)])
(and w
(let ([r (tell w firstResponder)])
(and r
(begin
(tell r keyDown: evt)
#t))))))))
(parameterize ([recurring-for-command #t])
(tell r keyDown: evt))
#t)))))))))
(define cocoa-mb (tell (tell MyBarMenu alloc) init))
(define current-mb #f)