fix cocoa pref menu
This commit is contained in:
parent
e9e180847a
commit
dedba7a441
|
@ -163,8 +163,6 @@
|
||||||
(tellv cocoa setFocusState: #:type _BOOL on?)
|
(tellv cocoa setFocusState: #:type _BOOL on?)
|
||||||
(tellv cocoa setNeedsDisplay: #:type _BOOL #t)))
|
(tellv cocoa setNeedsDisplay: #:type _BOOL #t)))
|
||||||
|
|
||||||
(define is-visible? #f)
|
|
||||||
|
|
||||||
;; Avoid multiple queued paints:
|
;; Avoid multiple queued paints:
|
||||||
(define paint-queued? #f)
|
(define paint-queued? #f)
|
||||||
;; To handle paint requests that happen while on-paint
|
;; To handle paint requests that happen while on-paint
|
||||||
|
@ -178,7 +176,7 @@
|
||||||
(set! paint-queued? #t)
|
(set! paint-queued? #t)
|
||||||
(queue-window-event this (lambda ()
|
(queue-window-event this (lambda ()
|
||||||
(set! paint-queued? #f)
|
(set! paint-queued? #f)
|
||||||
(when is-visible?
|
(when (is-shown-to-root?)
|
||||||
(set! now-drawing? #t)
|
(set! now-drawing? #t)
|
||||||
(fix-dc)
|
(fix-dc)
|
||||||
(on-paint)
|
(on-paint)
|
||||||
|
@ -268,7 +266,6 @@
|
||||||
(define tr 0)
|
(define tr 0)
|
||||||
|
|
||||||
(define/override (show on?)
|
(define/override (show on?)
|
||||||
(set! is-visible? on?)
|
|
||||||
;; FIXME: what if we're in the middle of an on-paint?
|
;; FIXME: what if we're in the middle of an on-paint?
|
||||||
(super show on?))
|
(super show on?))
|
||||||
|
|
||||||
|
|
|
@ -72,18 +72,20 @@
|
||||||
(tellv mb addItem: item)
|
(tellv mb addItem: item)
|
||||||
(tellv item release)))])
|
(tellv item release)))])
|
||||||
(let ([apple (tell (tell NSMenu alloc) initWithTitle: #:type _NSString "")])
|
(let ([apple (tell (tell NSMenu alloc) initWithTitle: #:type _NSString "")])
|
||||||
(let ([std (lambda (title sel [shortcut ""] [mods #f])
|
(let ([std (lambda (title sel [shortcut ""] [mods #f] [delegate? #f])
|
||||||
(let ([item (tell (tell NSMenuItem alloc)
|
(let ([item (tell (tell NSMenuItem alloc)
|
||||||
initWithTitle: #:type _NSString title
|
initWithTitle: #:type _NSString title
|
||||||
action: #:type _SEL sel
|
action: #:type _SEL sel
|
||||||
keyEquivalent: #:type _NSString shortcut)])
|
keyEquivalent: #:type _NSString shortcut)])
|
||||||
(when mods
|
(when mods
|
||||||
(tellv item setKeyEquivalentModifierMask: #:type _NSInteger mods))
|
(tellv item setKeyEquivalentModifierMask: #:type _NSInteger mods))
|
||||||
(tellv item setTarget: app)
|
(tellv item setTarget: (if delegate?
|
||||||
|
(tell app delegate)
|
||||||
|
app))
|
||||||
(tellv apple addItem: item)
|
(tellv apple addItem: item)
|
||||||
(tellv item release)))])
|
(tellv item release)))])
|
||||||
(std (format "About ~a" app-name) (selector orderFrontStandardAboutPanel:))
|
(std (format "About ~a" app-name) (selector orderFrontStandardAboutPanel:))
|
||||||
(std "Preferences..." (selector openPreferences:))
|
(std "Preferences..." (selector openPreferences:) "," #f #t)
|
||||||
(tellv apple addItem: (tell NSMenuItem separatorItem))
|
(tellv apple addItem: (tell NSMenuItem separatorItem))
|
||||||
(let ([services (tell (tell NSMenu alloc) initWithTitle: #:type _NSString "Services")])
|
(let ([services (tell (tell NSMenu alloc) initWithTitle: #:type _NSString "Services")])
|
||||||
(tellv app setServicesMenu: services)
|
(tellv app setServicesMenu: services)
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
"const.rkt"
|
"const.rkt"
|
||||||
"types.rkt"
|
"types.rkt"
|
||||||
"../common/queue.rkt"
|
"../common/queue.rkt"
|
||||||
|
"../common/handlers.rkt"
|
||||||
"../../lock.rkt"
|
"../../lock.rkt"
|
||||||
"../common/freeze.rkt")
|
"../common/freeze.rkt")
|
||||||
(unsafe!)
|
(unsafe!)
|
||||||
|
@ -37,8 +38,13 @@
|
||||||
(queue-quit-event)
|
(queue-quit-event)
|
||||||
0]
|
0]
|
||||||
[-a _BOOL (openPreferences: [_id app])
|
[-a _BOOL (openPreferences: [_id app])
|
||||||
(log-error "prefs")
|
(queue-prefs-event)
|
||||||
#t])
|
#t]
|
||||||
|
[-a _BOOL (validateMenuItem: [_id menuItem])
|
||||||
|
(if (ptr-equal? (selector openPreferences:)
|
||||||
|
(tell #:type _SEL menuItem action))
|
||||||
|
(not (eq? (application-pref-handler) nothing-application-pref-handler))
|
||||||
|
(super-tell #:type _BOOL validateMenuItem: menuItem))])
|
||||||
|
|
||||||
(tellv app finishLaunching)
|
(tellv app finishLaunching)
|
||||||
|
|
||||||
|
|
|
@ -91,8 +91,7 @@
|
||||||
(init-properties [[(symbol-in button check-box choice
|
(init-properties [[(symbol-in button check-box choice
|
||||||
list-box list-box-dclick text-field
|
list-box list-box-dclick text-field
|
||||||
text-field-enter slider radio-box
|
text-field-enter slider radio-box
|
||||||
menu-popdown menu-popdown-none tab-panel
|
menu-popdown menu-popdown-none tab-panel)
|
||||||
menu)
|
|
||||||
event-type]
|
event-type]
|
||||||
;; FIXME: should have no default
|
;; FIXME: should have no default
|
||||||
'button])
|
'button])
|
||||||
|
|
|
@ -3,26 +3,31 @@
|
||||||
(provide application-file-handler
|
(provide application-file-handler
|
||||||
application-quit-handler
|
application-quit-handler
|
||||||
application-about-handler
|
application-about-handler
|
||||||
application-pref-handler)
|
application-pref-handler
|
||||||
|
|
||||||
|
nothing-application-pref-handler)
|
||||||
|
|
||||||
(define afh void)
|
(define afh void)
|
||||||
(define application-file-handler
|
(define application-file-handler
|
||||||
(case-lambda
|
(case-lambda
|
||||||
[(proc) (set! afh proc)]
|
[(proc) (set! afh proc)]
|
||||||
[() afh]))
|
[() afh]))
|
||||||
|
|
||||||
(define aqh void)
|
(define aqh void)
|
||||||
(define application-quit-handler
|
(define application-quit-handler
|
||||||
(case-lambda
|
(case-lambda
|
||||||
[(proc) (set! aqh proc)]
|
[(proc) (set! aqh proc)]
|
||||||
[() aqh]))
|
[() aqh]))
|
||||||
|
|
||||||
(define aah void)
|
(define aah void)
|
||||||
(define application-about-handler
|
(define application-about-handler
|
||||||
(case-lambda
|
(case-lambda
|
||||||
[(proc) (set! aah proc)]
|
[(proc) (set! aah proc)]
|
||||||
[() aah]))
|
[() aah]))
|
||||||
(define aph void)
|
|
||||||
|
(define (nothing-application-pref-handler) (void))
|
||||||
|
(define aph nothing-application-pref-handler)
|
||||||
(define application-pref-handler
|
(define application-pref-handler
|
||||||
(case-lambda
|
(case-lambda
|
||||||
[(proc) (set! aph proc)]
|
[(proc) (set! aph proc)]
|
||||||
[() aph]))
|
[() aph]))
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,8 @@
|
||||||
get-top-level-windows
|
get-top-level-windows
|
||||||
other-modal?
|
other-modal?
|
||||||
|
|
||||||
queue-quit-event)
|
queue-quit-event
|
||||||
|
queue-prefs-event)
|
||||||
|
|
||||||
;; ------------------------------------------------------------
|
;; ------------------------------------------------------------
|
||||||
;; This module must be instantiated only once:
|
;; This module must be instantiated only once:
|
||||||
|
@ -348,3 +349,7 @@
|
||||||
(define (queue-quit-event)
|
(define (queue-quit-event)
|
||||||
;; called in event-pump thread
|
;; called in event-pump thread
|
||||||
(queue-event main-eventspace (application-quit-handler) 'med))
|
(queue-event main-eventspace (application-quit-handler) 'med))
|
||||||
|
|
||||||
|
(define (queue-prefs-event)
|
||||||
|
;; called in event-pump thread
|
||||||
|
(queue-event main-eventspace (application-pref-handler) 'med))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user