feat: allow on_app_exit to override closing the application
This commit is contained in:
parent
cac3d0b5df
commit
ac95b571ec
2 changed files with 8 additions and 4 deletions
|
|
@ -449,8 +449,10 @@ impl<T: Application> Cosmic<T> {
|
|||
}
|
||||
|
||||
Message::Close => {
|
||||
self.app.on_app_exit();
|
||||
return self.close();
|
||||
return match self.app.on_app_exit() {
|
||||
Some(message) => self.app.update(message),
|
||||
None => self.close(),
|
||||
};
|
||||
}
|
||||
Message::SystemThemeModeChange(keys, mode) => {
|
||||
let mut cmds = vec![self.app.system_theme_mode_update(&keys, &mode)];
|
||||
|
|
|
|||
|
|
@ -494,8 +494,10 @@ where
|
|||
None
|
||||
}
|
||||
|
||||
/// Called before closing the application.
|
||||
fn on_app_exit(&mut self) {}
|
||||
/// Called before closing the application. Returning a message will override closing windows.
|
||||
fn on_app_exit(&mut self) -> Option<Self::Message> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Called when a window requests to be closed.
|
||||
fn on_close_requested(&self, id: window::Id) -> Option<Self::Message> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue