cocoa button fixes

This commit is contained in:
Matthew Flatt 2010-09-14 13:49:00 -06:00
parent 3a17b284a7
commit 221c423402
2 changed files with 11 additions and 8 deletions

View File

@ -22,6 +22,7 @@
(import-class NSButton NSView NSImageView) (import-class NSButton NSView NSImageView)
(define MIN-BUTTON-WIDTH 72) (define MIN-BUTTON-WIDTH 72)
(define BUTTON-EXTRA-WIDTH 12)
(define-objc-class MyButton NSButton (define-objc-class MyButton NSButton
#:mixins (FocusResponder KeyMouseResponder CursorDisplayer) #:mixins (FocusResponder KeyMouseResponder CursorDisplayer)
@ -62,11 +63,12 @@
(when (and (eq? event-type 'button) (when (and (eq? event-type 'button)
(string? label)) (string? label))
(let ([frame (tell #:type _NSRect cocoa frame)]) (let ([frame (tell #:type _NSRect cocoa frame)])
(when ((NSSize-width (NSRect-size frame)) . < . MIN-BUTTON-WIDTH) (tellv cocoa setFrame: #:type _NSRect
(tellv cocoa setFrame: #:type _NSRect (make-NSRect (NSRect-origin frame)
(make-NSRect (NSRect-origin frame) (make-NSSize (+ BUTTON-EXTRA-WIDTH
(make-NSSize MIN-BUTTON-WIDTH (max MIN-BUTTON-WIDTH
(NSSize-height (NSRect-size frame)))))))) (NSSize-width (NSRect-size frame))))
(NSSize-height (NSRect-size frame)))))))
cocoa)) cocoa))
(define cocoa (if (and button-type (define cocoa (if (and button-type

View File

@ -484,9 +484,10 @@
(void)) (void))
(define/public (set-focus) (define/public (set-focus)
(let ([w (tell cocoa window)]) (when (gets-focus?)
(when w (let ([w (tell cocoa window)])
(tellv w makeFirstResponder: (get-cocoa-content))))) (when w
(tellv w makeFirstResponder: (get-cocoa-content))))))
(define/public (on-set-focus) (void)) (define/public (on-set-focus) (void))
(define/public (on-kill-focus) (void)) (define/public (on-kill-focus) (void))