diff options
author | 2023-07-24 14:32:59 -0700 | |
---|---|---|
committer | 2023-07-24 14:32:59 -0700 | |
commit | 83c7870c569a2976923ee6243a19813094d44673 (patch) | |
tree | 70e3263bd9c7ac02ed8107d854edfccb5e90245f /core | |
parent | d53ccc857da4d4cda769904342aeb5a82a64f146 (diff) | |
download | iced-83c7870c569a2976923ee6243a19813094d44673.tar.gz iced-83c7870c569a2976923ee6243a19813094d44673.tar.bz2 iced-83c7870c569a2976923ee6243a19813094d44673.zip |
Moved `exit_on_close_request` to window settings. This now controls whether each INDIVIDUAL window should close on CloseRequested events.
Diffstat (limited to 'core')
-rw-r--r-- | core/src/window/event.rs | 3 | ||||
-rw-r--r-- | core/src/window/settings.rs | 11 |
2 files changed, 11 insertions, 3 deletions
diff --git a/core/src/window/event.rs b/core/src/window/event.rs index 3efce05e..f7759435 100644 --- a/core/src/window/event.rs +++ b/core/src/window/event.rs @@ -28,9 +28,6 @@ pub enum Event { RedrawRequested(Instant), /// The user has requested for the window to close. - /// - /// Usually, you will want to terminate the execution whenever this event - /// occurs. CloseRequested, /// A window was destroyed by the runtime. diff --git a/core/src/window/settings.rs b/core/src/window/settings.rs index 20811e83..eba27914 100644 --- a/core/src/window/settings.rs +++ b/core/src/window/settings.rs @@ -57,6 +57,16 @@ pub struct Settings { /// Platform specific settings. pub platform_specific: PlatformSpecific, + + /// Whether the window will close when the user requests it, e.g. when a user presses the + /// close button. + /// + /// This can be useful if you want to have some behavior that executes before the window is + /// actually destroyed. If you disable this, you must manually close the window with the + /// `window::close` command. + /// + /// By default this is enabled. + pub exit_on_close_request: bool, } impl Default for Settings { @@ -73,6 +83,7 @@ impl Default for Settings { level: Level::default(), icon: None, platform_specific: Default::default(), + exit_on_close_request: true, } } } |