diff --git a/crates/ui-egui/src/control/tests.rs b/crates/ui-egui/src/control/tests.rs index b97a2592bc8..5761661b1ac 100644 --- a/crates/ui-egui/src/control/tests.rs +++ b/crates/ui-egui/src/control/tests.rs @@ -675,15 +675,17 @@ fn agent_space_right_click_opens_the_hand_view_menu() { app.ui.canvas_tool_menu = None; app.ui.layer_menu = None; app.ui.brush_picker = None; - call(&mut app, &ctx, "ui.pointer", click(true, true)); - assert!(app.ui.canvas_tool_menu.as_ref().is_none_or(|m| m.anchor.is_none()), "{tool:?}: ⌘Space holds the Zoom, which has no menu"); + assert_eq!(call(&mut app, &ctx, "ui.pointer", click(true, true))["ok"], true, "{tool:?}"); + assert!(app.ui.canvas_tool_menu.is_none(), "{tool:?}: ⌘Space holds the Zoom, which has no menu"); + // ⌘ still makes it a ⌘/Ctrl+right-click, which lists the layers under the pointer (#307). + assert!(app.ui.layer_menu.is_some(), "{tool:?}: ⌘+right-click lists the layers"); app.ui.canvas_tool_menu = None; app.ui.layer_menu = None; app.ui.brush_picker = None; // ⌥Space holds the Zoom too: no view menu, and not the Move tool's layer list. let alt = json!({"space": true, "alt": true, "button": "secondary", "events": [{"kind":"down","x":8,"y":8},{"kind":"up","x":8,"y":8}]}); - call(&mut app, &ctx, "ui.pointer", alt); - assert!(app.ui.canvas_tool_menu.as_ref().is_none_or(|m| m.anchor.is_none()), "{tool:?}: ⌥Space opens no view menu"); + assert_eq!(call(&mut app, &ctx, "ui.pointer", alt)["ok"], true, "{tool:?}"); + assert!(app.ui.canvas_tool_menu.is_none(), "{tool:?}: ⌥Space opens no menu"); assert!(app.ui.layer_menu.is_none(), "{tool:?}: ⌥Space doesn't open the layer list"); } } diff --git a/crates/ui-egui/src/input/hold_keys/tests.rs b/crates/ui-egui/src/input/hold_keys/tests.rs index b692f4eda74..7ccd0ebc770 100644 --- a/crates/ui-egui/src/input/hold_keys/tests.rs +++ b/crates/ui-egui/src/input/hold_keys/tests.rs @@ -1104,3 +1104,29 @@ fn space_right_click_opens_the_hand_view_menu() { assert!(h.state().ui.canvas_tool_menu.is_none(), "{tool:?}: choosing closes the menu"); } } + +/// ⌘Space and ⌥Space hold the Zoom, not the Hand: a right-click opens no view menu (#11271). +/// With ⌥ it opens nothing, not even the held-over Move tool's layer list; with ⌘ it is still a +/// ⌘/Ctrl+right-click, which lists the layers under the pointer for any tool (#307). +#[test] +fn command_or_alt_space_right_click_opens_no_view_menu() { + for mods in [Modifiers::COMMAND, Modifiers::ALT] { + for tool in [Tool::Move, Tool::Brush] { + let mut h = harness(tool); + let p = screen(&h, 200.0, 150.0); + h.event(Event::PointerMoved(p)); + h.run_steps(1); + key(&mut h, Key::Space, true, mods); + h.event(Event::PointerButton { pos: p, button: PointerButton::Secondary, pressed: true, modifiers: mods }); + h.run_steps(1); + h.event(Event::PointerButton { pos: p, button: PointerButton::Secondary, pressed: false, modifiers: mods }); + h.run_steps(1); + key(&mut h, Key::Space, false, mods); + h.run_steps(2); + let view = h.state().ui.canvas_tool_menu.as_ref().is_some_and(|m| crate::canvas_tool_menu::rows(m) == crate::canvas_tool_menu::VIEW_MENU); + assert!(!view, "{mods:?} {tool:?}: no view menu"); + assert_eq!(h.state().ui.layer_menu.is_some(), mods.command, "{mods:?} {tool:?}: the layer list only for ⌘+right-click"); + assert_eq!(h.state().ui.tool, tool, "{mods:?} {tool:?}: the tool is kept"); + } + } +}