-
Notifications
You must be signed in to change notification settings - Fork 569
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
How can I exit an app if closed window? #674
Comments
This is a known issue tracked in #265. Right now the solution is to Ctrl+C the console app. |
indeed, this is a pretty easy fix if someone is interested, but I'm not going to get to it for a while. |
@usagi the place to fix this is https://github.com/xi-editor/druid/blob/master/druid/src/win_handler.rs#L223 |
@cmyr Thanks, I'm read around that and implementation of application.rs for each platforms. And try to it: fn remove_window(&mut self, window_id: WindowId) {
self.with_delegate(|del, data, env, ctx| del.window_removed(window_id, data, env, ctx));
// when closing the last window:
if let Some(mut win) = self.windows.remove(window_id) {
if self.windows.windows.is_empty() {
// on mac we need to keep the menu around
self.root_menu = win.menu.take();
//FIXME: on windows we need to shutdown the app here?
Application::quit(); // <-- fixing for the problem! It works and solve the problem for Windows. And it also works on GTK/Linux without a troubles. But, the method also effect to OSX and I saw your old comments for OSX:
Unfortunately, I have not OSX environment then I cannot fix the issue use the simple method without darty |
It should be noted that the shello example is closing normally when the button is pressed |
What I would recommend is just making this |
It would be great if it was an option for macOS. While most apps don't close when their last window closes, that doesn't mean none of them do. The ones that stay open are generally multi-window apps, and the ones that close are ones where there is only ever the one window. If the app has only the single window there's no way to make a new window once you close the main one, so it should just quit the app. I'm not suggesting doing any kind of auto-detection, but having a toggle would be nice. |
You as the programmer are free to exit if the last window is closed, but I would generally think of this as an anti-pattern; at the very least I can't think of an example of a 'well behaved' mac app that does this? Maybe things are relaxing as iOS becomes more dominant, I dunno. |
After a bit of investigation, I've identified a number of built-in mac apps that quit when their last window closes. They're all apps with only a single window: App Store, Notes, Reminders, Contacts, FaceTime, Calculator, and Dictionary |
Interesting, I didn't know that. Thanks! |
Expected behavor:
Actual behavor:
In the other words, how can I exit the
AppLauncher
's loop?The text was updated successfully, but these errors were encountered: