diff --git a/collects/mred/private/wx/cocoa/radio-box.rkt b/collects/mred/private/wx/cocoa/radio-box.rkt index 237ec581..558418df 100644 --- a/collects/mred/private/wx/cocoa/radio-box.rkt +++ b/collects/mred/private/wx/cocoa/radio-box.rkt @@ -26,6 +26,9 @@ #:mixins (FocusResponder KeyMouseResponder CursorDisplayer) [wxb] (-a _void (clicked: [_id sender]) + ;; In case we were in 0-item mode, switch to Radio mode to + ;; ensure that only one button is selected: + (tellv self setMode: #:type _int NSRadioModeMatrix) (queue-window*-event wxb (lambda (wx) (send wx clicked))))) (define-objc-class MyImageButtonCell NSButtonCell @@ -127,15 +130,21 @@ (if (= i -1) (begin ;; Need to change to NSListModeMatrix to disable all. - ;; It seem that we don't have to change the mode back, for some reason. (tellv (get-cocoa) setMode: #:type _int NSListModeMatrix) (tellv (get-cocoa) deselectAllCells)) - (tellv (get-cocoa) selectCellAtRow: #:type _NSInteger (if horiz? 0 i) - column: #:type _NSInteger (if horiz? i 0)))) + (begin + (tellv (get-cocoa) setMode: #:type _int NSRadioModeMatrix) + (tellv (get-cocoa) selectCellAtRow: #:type _NSInteger (if horiz? 0 i) + column: #:type _NSInteger (if horiz? i 0))))) (define/public (get-selection) - (if horiz? - (tell #:type _NSInteger (get-cocoa) selectedColumn) - (tell #:type _NSInteger (get-cocoa) selectedRow))) + (let ([c (tell (get-cocoa) selectedCell)] + [pos (if horiz? + (tell #:type _NSInteger (get-cocoa) selectedColumn) + (tell #:type _NSInteger (get-cocoa) selectedRow))]) + (if (and c + (positive? (tell #:type _NSInteger c state))) + pos + -1))) (define/public (number) count) (define/override (maybe-register-as-child parent on?)