File tree Expand file tree Collapse file tree 4 files changed +28
-22
lines changed
native/Avalonia.Native/src/OSX
samples/ControlCatalog/Pages Expand file tree Collapse file tree 4 files changed +28
-22
lines changed Original file line number Diff line number Diff line change @@ -175,9 +175,10 @@ -(CLASS_NAME*_Nonnull) initWithParent: (WindowBaseImpl*_Nonnull) parent content
175
175
176
176
_isExtended = false ;
177
177
178
- #ifdef IS_NSPANEL
179
- [self setCollectionBehavior: NSWindowCollectionBehaviorCanJoinAllSpaces|NSWindowCollectionBehaviorFullScreenAuxiliary];
180
- #endif
178
+ if (self.isDialog )
179
+ {
180
+ [self setCollectionBehavior: NSWindowCollectionBehaviorCanJoinAllSpaces|NSWindowCollectionBehaviorFullScreenAuxiliary];
181
+ }
181
182
182
183
return self;
183
184
}
@@ -259,6 +260,10 @@ -(bool)shouldTryToHandleEvents
259
260
-(void ) setEnabled : (bool )enable
260
261
{
261
262
_isEnabled = enable;
263
+
264
+ [[self standardWindowButton: NSWindowCloseButton] setEnabled: enable];
265
+ [[self standardWindowButton: NSWindowMiniaturizeButton] setEnabled: enable];
266
+ [[self standardWindowButton: NSWindowZoomButton] setEnabled: enable];
262
267
}
263
268
264
269
-(void )becomeKeyWindow
Original file line number Diff line number Diff line change 29
29
return ;
30
30
}
31
31
32
- for (id subview in Window.contentView .superview .subviews ) {
33
- if ([subview isKindOfClass: NSClassFromString (@" NSTitlebarContainerView" )]) {
34
- NSView *titlebarView = [subview subviews ][0 ];
35
- for (id button in titlebarView.subviews ) {
36
- if ([button isKindOfClass: [NSButton class ]]) {
37
- if (_isClientAreaExtended) {
38
- auto wantsChrome = (_extendClientHints & AvnSystemChrome) || (_extendClientHints & AvnPreferSystemChrome);
39
-
40
- [button setHidden: !wantsChrome];
41
- } else {
42
- [button setHidden: (_decorations != SystemDecorationsFull)];
43
- }
44
-
45
- [button setWantsLayer: true ];
46
- }
47
- }
48
- }
49
- }
32
+ bool wantsChrome = (_extendClientHints & AvnSystemChrome) || (_extendClientHints & AvnPreferSystemChrome);
33
+ bool hasTrafficLights = _isClientAreaExtended ? !wantsChrome : _decorations != SystemDecorationsFull;
34
+
35
+ [[Window standardWindowButton: NSWindowCloseButton] setHidden: hasTrafficLights];
36
+ [[Window standardWindowButton: NSWindowMiniaturizeButton] setHidden: hasTrafficLights];
37
+ [[Window standardWindowButton: NSWindowZoomButton] setHidden: hasTrafficLights];
50
38
}
51
39
52
40
void WindowImpl::OnInitialiseNSWindow (){
Original file line number Diff line number Diff line change 20
20
Text =" Window dialogs" />
21
21
<Button Name =" DecoratedWindow" >Decorated _window</Button >
22
22
<Button Name =" DecoratedWindowDialog" >Decorated w_indow (dialog)</Button >
23
- <Button Name =" Dialog" >_Dialog</Button >
23
+ <Button Name =" Dialog" ToolTip.Tip= " Shows a dialog " >_Dialog</Button >
24
24
<Button Name =" DialogNoTaskbar" >Dialog (_No taskbar icon)</Button >
25
25
<Button Name =" OwnedWindow" >Own_ed window</Button >
26
26
<Button Name =" OwnedWindowNoTaskbar" >Owned window (No tas_kbar icon)</Button >
Original file line number Diff line number Diff line change @@ -142,6 +142,7 @@ public DialogsPage()
142
142
private Window CreateSampleWindow ( )
143
143
{
144
144
Button button ;
145
+ Button dialogButton ;
145
146
146
147
var window = new Window
147
148
{
@@ -158,13 +159,25 @@ private Window CreateSampleWindow()
158
159
HorizontalAlignment = HorizontalAlignment . Center ,
159
160
Content = "Click to close" ,
160
161
IsDefault = true
162
+ } ) ,
163
+ ( dialogButton = new Button
164
+ {
165
+ HorizontalAlignment = HorizontalAlignment . Center ,
166
+ Content = "Dialog" ,
167
+ IsDefault = false
161
168
} )
162
169
}
163
170
} ,
164
171
WindowStartupLocation = WindowStartupLocation . CenterOwner
165
172
} ;
166
173
167
174
button . Click += ( _ , __ ) => window . Close ( ) ;
175
+ dialogButton . Click += ( _ , __ ) =>
176
+ {
177
+ var dialog = CreateSampleWindow ( ) ;
178
+ dialog . Height = 200 ;
179
+ dialog . ShowDialog ( window ) ;
180
+ } ;
168
181
169
182
return window ;
170
183
}
You can’t perform that action at this time.
0 commit comments