cocoa: fix problems with `radio-box%' in no-selection mode
Closes PR 11708 Merge to 5.1 original commit: 5d1b78384d390520edf970021bc0c144f78c259e
This commit is contained in:
parent
e15a65221e
commit
f04e67e91f
|
@ -26,6 +26,9 @@
|
||||||
#:mixins (FocusResponder KeyMouseResponder CursorDisplayer)
|
#:mixins (FocusResponder KeyMouseResponder CursorDisplayer)
|
||||||
[wxb]
|
[wxb]
|
||||||
(-a _void (clicked: [_id sender])
|
(-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)))))
|
(queue-window*-event wxb (lambda (wx) (send wx clicked)))))
|
||||||
|
|
||||||
(define-objc-class MyImageButtonCell NSButtonCell
|
(define-objc-class MyImageButtonCell NSButtonCell
|
||||||
|
@ -127,15 +130,21 @@
|
||||||
(if (= i -1)
|
(if (= i -1)
|
||||||
(begin
|
(begin
|
||||||
;; Need to change to NSListModeMatrix to disable all.
|
;; 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) setMode: #:type _int NSListModeMatrix)
|
||||||
(tellv (get-cocoa) deselectAllCells))
|
(tellv (get-cocoa) deselectAllCells))
|
||||||
(tellv (get-cocoa) selectCellAtRow: #:type _NSInteger (if horiz? 0 i)
|
(begin
|
||||||
column: #:type _NSInteger (if horiz? i 0))))
|
(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)
|
(define/public (get-selection)
|
||||||
(if horiz?
|
(let ([c (tell (get-cocoa) selectedCell)]
|
||||||
(tell #:type _NSInteger (get-cocoa) selectedColumn)
|
[pos (if horiz?
|
||||||
(tell #:type _NSInteger (get-cocoa) selectedRow)))
|
(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/public (number) count)
|
||||||
|
|
||||||
(define/override (maybe-register-as-child parent on?)
|
(define/override (maybe-register-as-child parent on?)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user