Skip to content

Commit 9bcc786

Browse files
committed
Mac OS: repairs for enable state, menus, and tab panels
Make sure a control added to a disabled window starts out disabled. Fix renaming of menus in a menu bar. Put tab-panel content properly in the containing view, and make disabling a tab-panel control work for Tahoe.
1 parent fda5f7e commit 9bcc786

5 files changed

Lines changed: 29 additions & 12 deletions

File tree

gui-lib/mred/private/wx/cocoa/gauge.rkt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161

6262
(define/override (enable on?) (void))
6363
(define/override (is-window-enabled?) #t)
64+
(define/override (is-enabled-to-root?) #t)
6465

6566
(define/public (get-range)
6667
(inexact->exact (floor (tell #:type _double cocoa maxValue))))

gui-lib/mred/private/wx/cocoa/item.rkt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434

3535
(defclass item% window%
3636
(inherit get-cocoa
37-
is-window-enabled?)
37+
is-window-enabled?
38+
is-enabled-to-root?)
3839

3940
(init-field callback)
4041

@@ -54,5 +55,8 @@
5455
(def/public-unimplemented get-label)
5556
(super-new)
5657

58+
(unless (is-enabled-to-root?)
59+
(tellv (get-cocoa-control) setEnabled: #:type _BOOL #false))
60+
5761
(define/public (init-font cocoa font)
5862
(install-control-font cocoa font)))

gui-lib/mred/private/wx/cocoa/menu-bar.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@
203203
(list (cons (car i) (cons str (cddr i)))))
204204
(drop menus (add1 pos))))
205205
(when (eq? current-mb this)
206-
(tellv (tell cocoa-mb itemAtIndex: #:type _NSInteger 1)
206+
(tellv (tell (tell cocoa-mb itemAtIndex: #:type _NSInteger 1) submenu)
207207
setTitle: #:type _NSString (clean-menu-label str))))
208208

209209
(define/public (do-on-menu-click)

gui-lib/mred/private/wx/cocoa/tab-panel.rkt

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
(define NSDefaultControlTint 0)
4444
(define NSClearControlTint 7)
4545

46-
(import-class NSView NSTabView NSTabViewItem)
46+
(import-class NSView NSTabView NSTabViewItem NSSegmentedControl)
4747
(define TabBarControl
4848
(cond
4949
[(not tab-ok?) #f]
@@ -126,6 +126,7 @@
126126
labels)
127127
(inherit get-cocoa register-as-child
128128
is-window-enabled?
129+
is-enabled-to-root?
129130
block-mouse-events
130131
refresh)
131132

@@ -168,11 +169,17 @@
168169
(tellv i setResizeTabsToFitTotalWidth: #:type _BOOL #t))
169170
i)))
170171

172+
(define content-cocoa
173+
(as-objc-allocation
174+
(tell (tell NSView alloc)
175+
initWithFrame: #:type _NSRect (tell #:type _NSRect tabv-cocoa contentRect))))
176+
171177
(define item-cocoas
172178
(for/list ([lbl (in-list labels)])
173179
(let ([item (as-objc-allocation
174180
(tell (tell NSTabViewItem alloc) initWithIdentifier: #f))])
175181
(tellv item setLabel: #:type _NSString (label->plain-label lbl))
182+
(tellv item setView: content-cocoa)
176183
(when (and has-close?
177184
use-mm?)
178185
(tellv item setHasCloseButton: #:type _BOOL #t))
@@ -185,12 +192,6 @@
185192
(tellv tabv-cocoa setFrame: #:type _NSRect (make-NSRect (make-init-point x y) sz))
186193
(tellv tabv-cocoa setDelegate: tabv-cocoa)))
187194

188-
(define content-cocoa
189-
(as-objc-allocation
190-
(tell (tell NSView alloc)
191-
initWithFrame: #:type _NSRect (tell #:type _NSRect tabv-cocoa contentRect))))
192-
(tellv tabv-cocoa addSubview: content-cocoa)
193-
194195
(define/override (get-cocoa-content) content-cocoa)
195196
(define/override (get-cocoa-cursor-content) tabv-cocoa)
196197
(define/override (set-size x y w h)
@@ -241,6 +242,7 @@
241242
(let ([item (as-objc-allocation
242243
(tell (tell NSTabViewItem alloc) initWithIdentifier: #f))])
243244
(tellv item setLabel: #:type _NSString (label->plain-label lbl))
245+
(tellv item setView: content-cocoa)
244246
(when (and has-close?
245247
use-mm?)
246248
(tellv item setHasCloseButton: #:type _BOOL #t))
@@ -279,7 +281,7 @@
279281
(super-new [parent parent]
280282
[cocoa cocoa]
281283
[no-show? (memq 'deleted style)])
282-
284+
283285
(when control-cocoa
284286
(set-ivar! control-cocoa wxb (->wxb this)))
285287

@@ -291,7 +293,17 @@
291293
(if on? NSDefaultControlTint NSClearControlTint))
292294
(when control-cocoa
293295
(unless use-mm?
294-
(tellv control-cocoa setEnabled: #:type _BOOL on?)))))
296+
(tellv control-cocoa seteEnabled: #:type _BOOL on?)))
297+
(when (version-26.0-or-later?)
298+
(when (eq? cocoa tabv-cocoa)
299+
(let ([subviews (tell cocoa subviews)])
300+
(for ([i (in-range 0 (tell #:type _NSUInteger subviews count))])
301+
(define c (tell subviews objectAtIndex: #:type _NSUInteger i))
302+
(when (tell #:type _BOOL c isKindOfClass: (tell NSSegmentedControl class))
303+
(tellv c setEnabled: #:type _BOOL on?))))))))
304+
305+
(unless (is-enabled-to-root?)
306+
(enable-window #f))
295307

296308
(define/override (can-accept-focus?)
297309
(and (not control-cocoa)

gui-lib/mred/private/wx/cocoa/window.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@
619619
(set-ivar! cocoa wxb (->wxb this))
620620

621621
(unless no-show?
622-
(show #t))
622+
(show #t))
623623

624624
(define/public (focus-is-on on?)
625625
(void))

0 commit comments

Comments
 (0)