diff options
Diffstat (limited to 'runtime/src/window.rs')
-rw-r--r-- | runtime/src/window.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/runtime/src/window.rs b/runtime/src/window.rs index 2136d64d..4d97d5ee 100644 --- a/runtime/src/window.rs +++ b/runtime/src/window.rs @@ -15,6 +15,10 @@ use crate::core::{Point, Size}; use crate::futures::event; use crate::futures::Subscription; +pub use raw_window_handle; + +use raw_window_handle::WindowHandle; + /// Subscribes to the frames of the window of the running application. /// /// The resulting [`Subscription`] will produce items at a rate equal to the @@ -170,6 +174,19 @@ pub fn change_icon<Message>(id: Id, icon: Icon) -> Command<Message> { Command::single(command::Action::Window(Action::ChangeIcon(id, icon))) } +/// Runs the given callback with the native window handle for the window with the given id. +/// +/// Note that if the window closes before this call is processed the callback will not be run. +pub fn run_with_handle<Message>( + id: Id, + f: impl FnOnce(&WindowHandle<'_>) -> Message + 'static, +) -> Command<Message> { + Command::single(command::Action::Window(Action::RunWithHandle( + id, + Box::new(f), + ))) +} + /// Captures a [`Screenshot`] from the window. pub fn screenshot<Message>( id: Id, |