summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-06-16 20:15:55 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-06-16 20:15:55 +0200
commitb5c5a016c4f2b608a740b37c494186557a064f48 (patch)
tree2676e3cb8ec17c5bf1cd561d97932ae302551dfd
parentad2e4c535af01453777e330aa828db6988f9c4de (diff)
downloadiced-b5c5a016c4f2b608a740b37c494186557a064f48.tar.gz
iced-b5c5a016c4f2b608a740b37c494186557a064f48.tar.bz2
iced-b5c5a016c4f2b608a740b37c494186557a064f48.zip
Rename `window::closings` to `window::close_events`
-rw-r--r--examples/multi_window/src/main.rs2
-rw-r--r--runtime/src/window.rs32
2 files changed, 28 insertions, 6 deletions
diff --git a/examples/multi_window/src/main.rs b/examples/multi_window/src/main.rs
index ba764654..b82ad1f3 100644
--- a/examples/multi_window/src/main.rs
+++ b/examples/multi_window/src/main.rs
@@ -150,7 +150,7 @@ impl multi_window::Application for Example {
}
fn subscription(&self) -> Subscription<Self::Message> {
- window::closings().map(Message::WindowClosed)
+ window::close_events().map(Message::WindowClosed)
}
}
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> {