-
Notifications
You must be signed in to change notification settings - Fork 440
Add initial support for Multiple Windows on MacOS #2260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6401190
e35a411
25612f3
85c4b2d
69134a0
1c3a03b
861a8ea
04a03c0
e22d3b8
dc85c90
9dc8ff2
19d39a3
8b2b05c
a32b73e
a3f64ec
393d6ee
bb5a5d6
54cc445
88100ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,9 +9,26 @@ public partial class App : Application | |
public App(AppShell appShell) | ||
{ | ||
InitializeComponent(); | ||
|
||
this.appShell = appShell; | ||
} | ||
|
||
#if MACCATALYST | ||
protected override Window CreateWindow(IActivationState? activationState) | ||
{ | ||
Window window = base.CreateWindow(activationState); | ||
window.Destroying += (object? sender, EventArgs args) => | ||
{ | ||
if (Current?.Windows?.Count - 1 == 0) | ||
{ | ||
// Exit the app when the last window closes | ||
// This ensures app closes when last window closes on Mac | ||
Environment.Exit(0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a correct thing to do though? I honestly don't know hence the question. I ask primarily because of this https://superuser.com/questions/53935/getting-mac-os-x-applications-to-close-after-last-window-closed/53940#53940 answer. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ^^ @ne0rrmatrix friendly ping |
||
} | ||
}; | ||
return window; | ||
} | ||
|
||
#else | ||
protected override Window CreateWindow(IActivationState? activationState) => new(appShell); | ||
#endif | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
using Foundation; | ||
using Microsoft.Maui; | ||
using ObjCRuntime; | ||
using UIKit; | ||
|
||
namespace CommunityToolkit.Maui.Sample.Platforms.MacCatalyst; | ||
|
||
[Register("SceneDelegate")] | ||
public class SceneDelegate : MauiUISceneDelegate | ||
{ | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, e.g., on Windows the call is
new Window(appShell)
and on Mac Catalyst it isbase.CreateWindow(activationState)
.Is this by design that
appShell
is not passed in? Again honest question.