diff options
author | 2024-10-11 11:51:44 +0200 | |
---|---|---|
committer | 2025-01-06 23:20:51 +0100 | |
commit | ca8aaf9b8daa3d8b925165fb912af425438d4e79 (patch) | |
tree | d6596358956f2d1df41caa69f31ea1273d775464 | |
parent | 717b296cdb17f22b410e2985b58e73af2199bfcc (diff) | |
download | iced-ca8aaf9b8daa3d8b925165fb912af425438d4e79.tar.gz iced-ca8aaf9b8daa3d8b925165fb912af425438d4e79.tar.bz2 iced-ca8aaf9b8daa3d8b925165fb912af425438d4e79.zip |
add Task and Action for changing a window title
-rw-r--r-- | runtime/src/window.rs | 8 | ||||
-rw-r--r-- | winit/src/program.rs | 5 |
2 files changed, 13 insertions, 0 deletions
diff --git a/runtime/src/window.rs b/runtime/src/window.rs index 0ebdba2f..b5c6ee50 100644 --- a/runtime/src/window.rs +++ b/runtime/src/window.rs @@ -73,6 +73,9 @@ pub enum Action { /// Get the current [`Mode`] of the window. GetMode(Id, oneshot::Sender<Mode>), + /// Change the title of the window. + ChangeTitle(Id, String), + /// Toggle the window to maximized or back ToggleMaximize(Id), @@ -368,6 +371,11 @@ pub fn change_level<T>(id: Id, level: Level) -> Task<T> { task::effect(crate::Action::Window(Action::ChangeLevel(id, level))) } +/// Changes the title of the window. +pub fn change_title<T>(id: Id, title: String) -> Task<T> { + task::effect(crate::Action::Window(Action::ChangeTitle(id, title))) +} + /// Show the [system menu] at cursor position. /// /// [system menu]: https://en.wikipedia.org/wiki/Common_menus_in_Microsoft_Windows#System_menu diff --git a/winit/src/program.rs b/winit/src/program.rs index cc19a4e0..052b36b0 100644 --- a/winit/src/program.rs +++ b/winit/src/program.rs @@ -1291,6 +1291,11 @@ fn run_action<P, C>( ); } } + window::Action::ChangeTitle(id, title) => { + if let Some(window) = window_manager.get_mut(id) { + window.raw.set_title(&title); + } + } window::Action::GetSize(id, channel) => { if let Some(window) = window_manager.get_mut(id) { let size = window |