diff --git a/examples/gallery/pages/menus/rows.rs b/examples/gallery/pages/menus/rows.rs index 567e271..a4b0d58 100644 --- a/examples/gallery/pages/menus/rows.rs +++ b/examples/gallery/pages/menus/rows.rs @@ -211,6 +211,24 @@ pub fn hosts(window: &mut Window, cx: &mut App) -> impl IntoElement + use<> { pub fn context(window: &mut Window, cx: &mut App) -> impl IntoElement + use<> { let (last, caption) = ran("context-ran", window, cx); let menu = Menu::new() + .buttons([ + MenuItem::new("Cut") + .icon(IconName::Scissors) + .keys("secondary-x") + .on_click(run(&last, "cut")), + MenuItem::new("Copy") + .icon(IconName::Copy) + .keys("secondary-c") + .on_click(run(&last, "copy")), + MenuItem::new("Paste") + .icon(IconName::Clipboard) + .keys("secondary-v") + .on_click(run(&last, "paste")), + MenuItem::new("Delete") + .icon(IconName::Trash2) + .disabled(true), + ]) + .separator() .item( MenuItem::new("Back") .icon(IconName::ArrowLeft) @@ -242,7 +260,7 @@ pub fn context(window: &mut Window, cx: &mut App) -> impl IntoElement + use<> { let theme = cx.theme(); section( "ContextMenu", - "A right click opens the menu where it lands; it stays inside the window.", + "A right click opens the menu where it lands; it stays inside the window. A row of icon buttons heads it; arrows cross the row.", cx, ) .child(specimen( diff --git a/src/menus/draw.rs b/src/menus/draw.rs index 479114a..8f59a47 100644 --- a/src/menus/draw.rs +++ b/src/menus/draw.rs @@ -1,6 +1,6 @@ use gpui::{ AnyElement, App, Div, ElementId, Entity, FontWeight, InteractiveElement, IntoElement, - MouseButton, ParentElement, Stateful, Styled, div, prelude::*, + MouseButton, ParentElement, Role, SharedString, Stateful, Styled, div, prelude::*, }; use super::{ @@ -10,7 +10,7 @@ use super::{ use crate::{ forms::{Run, surface}, navigation::marked, - primitives::{Icon, IconName}, + primitives::{Icon, IconName, Tooltip}, theme::{ActiveTheme, ControlSize, IconSize, Radius, TextSize}, typography::KbdCombo, }; @@ -82,6 +82,50 @@ fn row(item: &MenuItem, ix: usize, current: bool, cx: &App) -> Stateful