cocoa: fix focus method

Don't confuse "should the Tab key advance the focus to this window?"
with "can this window have the focus?".
This commit is contained in:
Matthew Flatt 2015-01-11 11:05:36 -07:00
parent d0561137b5
commit 60611bc081
5 changed files with 7 additions and 6 deletions

View File

@ -814,7 +814,7 @@
(not (send e button-down? 'left)) (not (send e button-down? 'left))
(not (on-menu-click? e))))) (not (on-menu-click? e)))))
(define/override (gets-focus?) (define/override (can-accept-focus?)
wants-focus?) wants-focus?)
(define/override (can-be-responder?) (define/override (can-be-responder?)
(and wants-focus? (is-enabled-to-root?))) (and wants-focus? (is-enabled-to-root?)))

View File

@ -44,7 +44,7 @@
(let ([on? (and on? (is-window-enabled?))]) (let ([on? (and on? (is-window-enabled?))])
(tellv (get-cocoa-control) setEnabled: #:type _BOOL on?))) (tellv (get-cocoa-control) setEnabled: #:type _BOOL on?)))
(define/override (gets-focus?) (define/override (can-accept-focus?)
(tell #:type _BOOL (get-cocoa-control) canBecomeKeyView)) (tell #:type _BOOL (get-cocoa-control) canBecomeKeyView))
(define/public (command e) (define/public (command e)

View File

@ -117,7 +117,7 @@
[else [else
(tellv (get-cocoa) setImage: (bitmap->image label))])) (tellv (get-cocoa) setImage: (bitmap->image label))]))
(define/override (gets-focus?) #f) (define/override (can-accept-focus?) #f)
(define/public (set-preferred-size) (define/public (set-preferred-size)
(tellv (get-cocoa) sizeToFit) (tellv (get-cocoa) sizeToFit)

View File

@ -206,7 +206,7 @@
(when control-cocoa (when control-cocoa
(tellv control-cocoa setEnabled: #:type _BOOL on?)))) (tellv control-cocoa setEnabled: #:type _BOOL on?))))
(define/override (gets-focus?) (define/override (can-accept-focus?)
(and (not control-cocoa) (and (not control-cocoa)
(tell #:type _BOOL tabv-cocoa canBecomeKeyView))) (tell #:type _BOOL tabv-cocoa canBecomeKeyView)))
(define/override (get-cocoa-focus) (define/override (get-cocoa-focus)

View File

@ -751,7 +751,7 @@
(accept-drags-everywhere (or accept-drag? accept-parent-drag?)))) (accept-drags-everywhere (or accept-drag? accept-parent-drag?))))
(define/public (set-focus) (define/public (set-focus)
(when (and (gets-focus?) (when (and (can-accept-focus?)
(is-enabled-to-root?)) (is-enabled-to-root?))
(let ([w (tell cocoa window)]) (let ([w (tell cocoa window)])
(when w (when w
@ -912,7 +912,8 @@
(tellv content addCursorRect: #:type _NSRect r cursor: cursor-handle))))) (tellv content addCursorRect: #:type _NSRect r cursor: cursor-handle)))))
(define/public (get-cursor-width-delta) 0) (define/public (get-cursor-width-delta) 0)
(define/public (gets-focus?) #f) (define/public (can-accept-focus?) #f)
(define/public (gets-focus?) (can-accept-focus?))
(define/public (can-be-responder?) (is-enabled-to-root?)) (define/public (can-be-responder?) (is-enabled-to-root?))
(define/public (on-color-change) (define/public (on-color-change)