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

View File

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