diff options
author | 2024-02-13 05:02:54 +0100 | |
---|---|---|
committer | 2024-02-13 05:02:54 +0100 | |
commit | 52e207b89bb79dba210c581b790f794e6e0c94e8 (patch) | |
tree | 574699133deaceb86ed3511d3d57782c1d433f5c /runtime | |
parent | 7a1e10503697b68a4d6206551c34702ec8a69b79 (diff) | |
parent | a64cda6e3ed98fc805cb6331c3619e59840d4f75 (diff) | |
download | iced-52e207b89bb79dba210c581b790f794e6e0c94e8.tar.gz iced-52e207b89bb79dba210c581b790f794e6e0c94e8.tar.bz2 iced-52e207b89bb79dba210c581b790f794e6e0c94e8.zip |
Merge pull request #2243 from ids1024/show_window_menu
Add `show_window_menu` action
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/src/window.rs | 7 | ||||
-rw-r--r-- | runtime/src/window/action.rs | 9 |
2 files changed, 16 insertions, 0 deletions
diff --git a/runtime/src/window.rs b/runtime/src/window.rs index 4d97d5ee..04bcfcd8 100644 --- a/runtime/src/window.rs +++ b/runtime/src/window.rs @@ -160,6 +160,13 @@ pub fn change_level<Message>(id: Id, level: Level) -> Command<Message> { Command::single(command::Action::Window(Action::ChangeLevel(id, level))) } +/// Show the [system menu] at cursor position. +/// +/// [system menu]: https://en.wikipedia.org/wiki/Common_menus_in_Microsoft_Windows#System_menu +pub fn show_system_menu<Message>(id: Id) -> Command<Message> { + Command::single(command::Action::Window(Action::ShowSystemMenu(id))) +} + /// Fetches an identifier unique to the window, provided by the underlying windowing system. This is /// not to be confused with [`Id`]. pub fn fetch_id<Message>( diff --git a/runtime/src/window/action.rs b/runtime/src/window/action.rs index 86d58528..9bfc2b62 100644 --- a/runtime/src/window/action.rs +++ b/runtime/src/window/action.rs @@ -81,6 +81,11 @@ pub enum Action<T> { GainFocus(Id), /// Change the window [`Level`]. ChangeLevel(Id, Level), + /// Show the system menu at cursor position. + /// + /// ## Platform-specific + /// Android / iOS / macOS / Orbital / Web / X11: Unsupported. + ShowSystemMenu(Id), /// Fetch the raw identifier unique to the window. FetchId(Id, Box<dyn FnOnce(u64) -> T + 'static>), /// Change the window [`Icon`]. @@ -141,6 +146,7 @@ impl<T> Action<T> { } Self::GainFocus(id) => Action::GainFocus(id), Self::ChangeLevel(id, level) => Action::ChangeLevel(id, level), + Self::ShowSystemMenu(id) => Action::ShowSystemMenu(id), Self::FetchId(id, o) => { Action::FetchId(id, Box::new(move |s| f(o(s)))) } @@ -200,6 +206,9 @@ impl<T> fmt::Debug for Action<T> { Self::ChangeLevel(id, level) => { write!(f, "Action::ChangeLevel({id:?}, {level:?})") } + Self::ShowSystemMenu(id) => { + write!(f, "Action::ShowSystemMenu({id:?})") + } Self::FetchId(id, _) => write!(f, "Action::FetchId({id:?})"), Self::ChangeIcon(id, _icon) => { write!(f, "Action::ChangeIcon({id:?})") |