diff options
author | 2024-01-12 22:57:52 -0800 | |
---|---|---|
committer | 2024-02-13 04:45:07 +0100 | |
commit | f93a6d740ac4cb09720bcb502b04e9a3d993bdba (patch) | |
tree | 5432c487cd412bcac1c96b228ae167b040132047 /runtime/src/window/action.rs | |
parent | 7a1e10503697b68a4d6206551c34702ec8a69b79 (diff) | |
download | iced-f93a6d740ac4cb09720bcb502b04e9a3d993bdba.tar.gz iced-f93a6d740ac4cb09720bcb502b04e9a3d993bdba.tar.bz2 iced-f93a6d740ac4cb09720bcb502b04e9a3d993bdba.zip |
Add `show_window_menu` action
Winit currently supports this only on Windows and Wayland.
This requests that a context menu is shown at the cursor position,
like the menu normally triggered by right clicking the title bar. This
is important for implementing client side decorations with Iced widgets.
Diffstat (limited to 'runtime/src/window/action.rs')
-rw-r--r-- | runtime/src/window/action.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/runtime/src/window/action.rs b/runtime/src/window/action.rs index 86d58528..d5c8c370 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 window menu at cursor position. + /// + /// ## Platform-specific + /// Android / iOS / macOS / Orbital / Web / X11: Unsupported. + ShowWindowMenu(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::ShowWindowMenu(id) => Action::ShowWindowMenu(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::ShowWindowMenu(id) => { + write!(f, "Action::ShowWindowMenu({id:?})") + } Self::FetchId(id, _) => write!(f, "Action::FetchId({id:?})"), Self::ChangeIcon(id, _icon) => { write!(f, "Action::ChangeIcon({id:?})") |