diff --git a/crates/ui-egui/src/canvas/canvas_tool_menu.rs b/crates/ui-egui/src/canvas/canvas_tool_menu.rs index 568e1f104e..b2e377e0ec 100644 --- a/crates/ui-egui/src/canvas/canvas_tool_menu.rs +++ b/crates/ui-egui/src/canvas/canvas_tool_menu.rs @@ -467,10 +467,11 @@ pub fn applies(tool: Tool) -> bool { /// A Magnetic Lasso border is being drawn on the document in front: a right-click opens no menu /// over it, and the border stays live, as in Photoshop (#11689). A border left on another /// document doesn't count, even before `magnetic_lasso_ui::frame` drops it: the control -/// channel's events run no frame. +/// channel's events run no frame. Nor does an ⌥-drag's freehand segment: that case wasn't +/// measured, so it keeps the menu it had. pub fn magnetic_drawing(app: &PhotocraftApp) -> bool { let m = &app.ui.magnetic; - m.active() && app.ui.tool == Tool::MagneticLasso && app.session.active().map(|d| d.doc.id.0) == Some(m.doc) + m.active() && !m.freehand && app.ui.tool == Tool::MagneticLasso && app.session.active().map(|d| d.doc.id.0) == Some(m.doc) } /// Tools whose canvas right-click opens the path menu ([`PEN_MENU`]): the Pen, and the Path diff --git a/crates/ui-egui/tests/it/magnetic_lasso_right_click.rs b/crates/ui-egui/tests/it/magnetic_lasso_right_click.rs index 99dd83997a..7e2079c8a4 100644 --- a/crates/ui-egui/tests/it/magnetic_lasso_right_click.rs +++ b/crates/ui-egui/tests/it/magnetic_lasso_right_click.rs @@ -94,6 +94,22 @@ fn agent_right_click_on_another_document_still_opens_the_selection_menu() { assert!(entries.iter().any(|e| e["id"] == "select.all"), "{menu}"); } +#[test] +fn agent_right_click_during_an_alt_drag_still_opens_the_selection_menu() { + // Not measured in Photoshop: a right-click while an ⌥-drag draws a freehand segment keeps + // today's behaviour, the selection menu. + let mut app = app(); + agent_click(&mut app, CORNERS[0], "left", false); + let events = json!([{"kind": "down", "x": CORNERS[1][0], "y": CORNERS[1][1]}, {"kind": "move", "x": 200.0, "y": 120.0}]); + pointer(&mut app, json!({"tool": "MagneticLasso", "alt": true, "events": events})); + assert!(app.ui.magnetic.freehand, "an ⌥-drag is drawing a freehand segment"); + + agent_click(&mut app, INSIDE, "right", false); + let (_, menu) = inspect(&mut app); + let entries = menu["entries"].as_array().expect("the selection menu opened"); + assert!(entries.iter().any(|e| e["id"] == "select.all"), "{menu}"); +} + #[test] fn agent_right_click_without_a_border_still_opens_the_selection_menu() { let mut app = app();