mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-01 14:16:49 -06:00
Type tool: a release away from the press doesn't convert the empty frame
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
4a65451d40
commit
717fcd6dec
@@ -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]
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user