diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 55881fea6a..708f985fe4 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -4639,9 +4639,9 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect: draw_clone_preview(app, &painter, &xf, xf.to_doc(p), output); } // The Type tool over a path shows Photoshop's area-type or type-on-a-path pointer (#218). - // Not while a type edit is open (a click then commits rather than starting new type), - // nor over type a click would edit. - let type_path = if matches!(tool, Tool::Type | Tool::VerticalType) && app.ui.text_edit.is_none() { + // Not while a type edit is open or a text box is dragged out, nor over type a click + // would edit (`hover_path_target`). + let type_path = if matches!(tool, Tool::Type | Tool::VerticalType) { let [x, y] = xf.to_doc(p); let shift = crate::workspace_ui::sticky_mods(app, ui.input(|i| i.modifiers)).shift; crate::type_tool::hover_path_target(app, x, y, shift) diff --git a/crates/ui-egui/src/type_tool.rs b/crates/ui-egui/src/type_tool.rs index f7b0aa3609..fd43ed6f7a 100644 --- a/crates/ui-egui/src/type_tool.rs +++ b/crates/ui-egui/src/type_tool.rs @@ -459,8 +459,13 @@ pub(crate) fn path_target(app: &PhotocraftApp, x: f64, y: f64) -> Option Option { + if app.ui.text_edit.is_some() || app.drag.is_some() { + return None; + } let target = path_target(app, x, y)?; (shift || hit_layer(app, x, y).is_none()).then_some(target) } diff --git a/crates/ui-egui/src/type_tool_tests.rs b/crates/ui-egui/src/type_tool_tests.rs index 8297cfd8fd..65fc3d2e18 100644 --- a/crates/ui-egui/src/type_tool_tests.rs +++ b/crates/ui-egui/src/type_tool_tests.rs @@ -2837,6 +2837,23 @@ fn clicking_on_a_path_outline_starts_type_on_the_path_where_clicked() { ); } +/// The path pointer shows what a click would do: none while a text box is dragged out over a +/// path (the release makes a box) or while a type edit is open (a click commits). +#[test] +fn the_path_pointer_is_off_while_dragging_a_text_box_or_editing() { + use crate::canvas::{ToolEvent, tool_event}; + let mut app = new_app(); + ellipse_layer(&mut app); + assert!(matches!(super::hover_path_target(&mut app, 400.0, 350.0, false), Some(PathClick::Area { .. })), "a hover inside the shape"); + tool_event(&mut app, ToolEvent::Down { x: 1200.0, y: 700.0, pressure: 1.0 }, Modifiers::NONE); + tool_event(&mut app, ToolEvent::Move { x: 400.0, y: 350.0, pressure: 1.0 }, Modifiers::NONE); + assert!(app.drag.is_some(), "dragging out a box"); + assert!(super::hover_path_target(&mut app, 400.0, 350.0, false).is_none(), "the drag makes a box, not area type"); + tool_event(&mut app, ToolEvent::Up { x: 400.0, y: 350.0 }, Modifiers::NONE); + assert!(app.ui.text_edit.is_some(), "the box is being edited"); + assert!(super::hover_path_target(&mut app, 400.0, 350.0, false).is_none(), "a click now commits"); +} + #[test] fn click_outside_paths_still_makes_point_text() { use photocraft_doc::text::TextShape;