diff options
author | 2024-06-16 20:15:55 +0200 | |
---|---|---|
committer | 2024-06-16 20:15:55 +0200 | |
commit | b5c5a016c4f2b608a740b37c494186557a064f48 (patch) | |
tree | 2676e3cb8ec17c5bf1cd561d97932ae302551dfd /runtime | |
parent | ad2e4c535af01453777e330aa828db6988f9c4de (diff) | |
download | iced-b5c5a016c4f2b608a740b37c494186557a064f48.tar.gz iced-b5c5a016c4f2b608a740b37c494186557a064f48.tar.bz2 iced-b5c5a016c4f2b608a740b37c494186557a064f48.zip |
Rename `window::closings` to `window::close_events`
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/src/window.rs | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/runtime/src/window.rs b/runtime/src/window.rs index 2ba3e796..956a20e1 100644 --- a/runtime/src/window.rs +++ b/runtime/src/window.rs @@ -155,10 +155,21 @@ pub fn frames() -> Subscription<Instant> { }) } -/// Subscribes to all window close requests of the running application. -pub fn close_requests() -> Subscription<Id> { +/// Subscribes to all window events of the running application. +pub fn events() -> Subscription<(Id, Event)> { event::listen_with(|event, _status, id| { - if let crate::core::Event::Window(Event::CloseRequested) = event { + if let crate::core::Event::Window(event) = event { + Some((id, event)) + } else { + None + } + }) +} + +/// Subscribes to all [`Event::Closed`] occurrences in the running application. +pub fn open_events() -> Subscription<Id> { + event::listen_with(|event, _status, id| { + if let crate::core::Event::Window(Event::Closed) = event { Some(id) } else { None @@ -166,8 +177,8 @@ pub fn close_requests() -> Subscription<Id> { }) } -/// Subscribes to all window closings of the running application. -pub fn closings() -> Subscription<Id> { +/// Subscribes to all [`Event::Closed`] occurrences in the running application. +pub fn close_events() -> Subscription<Id> { event::listen_with(|event, _status, id| { if let crate::core::Event::Window(Event::Closed) = event { Some(id) @@ -177,6 +188,17 @@ pub fn closings() -> Subscription<Id> { }) } +/// Subscribes to all [`Event::CloseRequested`] occurences in the running application. +pub fn close_requests() -> Subscription<Id> { + event::listen_with(|event, _status, id| { + if let crate::core::Event::Window(Event::CloseRequested) = event { + Some(id) + } else { + None + } + }) +} + /// Opens a new window with the given [`Settings`]; producing the [`Id`] /// of the new window on completion. pub fn open(settings: Settings) -> Task<Id> { |