From a108b2eebe210c774d07e436be5d73293dfea9eb Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 13 Jul 2024 12:53:06 +0200 Subject: Add `resize_events` subscription to `window` module --- runtime/src/window.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'runtime') diff --git a/runtime/src/window.rs b/runtime/src/window.rs index 815827d1..ee03f84f 100644 --- a/runtime/src/window.rs +++ b/runtime/src/window.rs @@ -194,6 +194,17 @@ pub fn close_events() -> Subscription { }) } +/// Subscribes to all [`Event::Resized`] occurrences in the running application. +pub fn resize_events() -> Subscription<(Id, Size)> { + event::listen_with(|event, _status, id| { + if let crate::core::Event::Window(Event::Resized(size)) = event { + Some((id, size)) + } else { + None + } + }) +} + /// Subscribes to all [`Event::CloseRequested`] occurences in the running application. pub fn close_requests() -> Subscription { event::listen_with(|event, _status, id| { -- cgit