DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Type tool: a release away from the press doesn't convert the empty frame
paaspaas00717fcd6decef
diff --git a/crates/tools/src/tests.rs b/crates/tools/src/tests.rsindex 5295708cb..2e5ded8a3 100644--- a/crates/tools/src/tests.rs+++ b/crates/tools/src/tests.rs@@ -1080,6 +1080,9 @@ fn type_tool_drag_over_an_empty_frame_draws_a_new_text_frame() {assert!(t.pointer(&cx, &PointerEvent::new(PointerKind::Down, x, y)).is_empty());let a = t.pointer(&cx, &PointerEvent::new(PointerKind::Up, x, y));assert!(matches!(&a[..], [Action::Exec(cmd, p)] if cmd == "text.placeCaret" && p["frame"] == id.0), "{a:?}");+ // A release away from the press with no drag in between isn't a click: no caret, no conversion.+ assert!(t.pointer(&cx, &PointerEvent::new(PointerKind::Down, x, y)).is_empty());+ assert!(t.pointer(&cx, &PointerEvent::new(PointerKind::Up, x1, y1)).is_empty());}#[test]diff --git a/crates/tools/src/text.rs b/crates/tools/src/text.rsindex c8cb778a9..e7ac00355 100644--- a/crates/tools/src/text.rs+++ b/crates/tools/src/text.rs@@ -333,8 +333,12 @@ impl Tool for TypeTool {self.selecting = None;return vec![Action::Commit];}- // A click in an empty frame: it becomes a text frame with the caret in it.+ // A click in an empty frame: it becomes a text frame with the caret in it. A release+ // away from the press (with no drag in between) isn't a click: nothing changes.if let Some((fid, at)) = self.convert.take() {+ if start.is_some_and(|a| (ev.pos - a).hypot() >= cx.tol(3.0)) {+ return vec![];+ }return vec![Action::Exec("text.placeCaret".into(), json!({"frame": fid, "point": [at.x, at.y]}))];}// Ends a press in text: drops dragged text, or is ignored by the engine.