1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 13:50:04 -04:00

eframe: allow aborting an exit event (#1038)

This commit is contained in:
Erlend Walstad
2022-01-17 18:45:09 +01:00
committed by GitHub
parent 87ac7446da
commit ab77099781
4 changed files with 79 additions and 4 deletions

View File

@@ -144,7 +144,20 @@ pub trait App {
/// where `APPNAME` is what is returned by [`Self::name()`].
fn save(&mut self, _storage: &mut dyn Storage) {}
/// Called once on shutdown (before or after [`Self::save`])
/// Called before an exit that can be aborted.
/// By returning `false` the exit will be aborted. To continue the exit return `true`.
///
/// A scenario where this method will be run is after pressing the close button on a native
/// window, which allows you to ask the user whether they want to do something before exiting.
/// See the example `eframe/examples/confirm_exit.rs` for practical usage.
///
/// It will _not_ be called on the web or when the window is forcefully closed.
fn on_exit_event(&mut self) -> bool {
true
}
/// Called once on shutdown (before or after [`Self::save`]). If you need to abort an exit use
/// [`Self::on_exit_event`]
fn on_exit(&mut self) {}
// ---------