Skip to content

Canvas: double-clicking type with a selection tool puts the caret there - #284

Merged
bflatastic merged 2 commits into
storytold:mainfrom
theironchef:fix/double-click-type-caret
Oct 7, 2026
Merged

bflatastic merged 2 commits into
storytold:mainfrom
theironchef:fix/double-click-type-caret

Conversation

@theironchef

Copy link
Copy Markdown
Contributor

Fixes #283.

Problem: the Selection tool's double-click on type returns only SwitchTool("type") (crates/tools/src/select.rs), so the Type tool started idle, with nothing being edited and no caret. Typing right after went to the shortcut handler instead of the text. X, for one, swapped the selected text's fill and stroke and turned it into outlined type.

Change: in handle_input (crates/ui-egui/src/canvas.rs), when a double-click switches the tool to Type, the canvas passes the double-click's position on to the Type tool as a click (Down + Up). A click on existing type already starts editing it with the caret at the clicked character (edit_at), so typing edits the text straight away, as in the reference app. Other double-clicks are unchanged: group isolation, exiting isolation, and the Type tool's own word selection.

Tests

  • New canvas::tests::double_clicking_type_with_the_selection_tool_puts_the_caret_there: a headless double-click in the middle of "Hello world" with the Selection tool leaves the Type tool editing that text, with the caret strictly inside it. Typing X then inserts at the caret.
  • With the new block disabled, the test fails (nothing is being edited).
  • cargo test -p vectorcraft-ui-egui: 557 passed. cargo test -p vectorcraft-engine --lib persp_text: 12 passed (perspective type's double-click path).
  • cargo clippy -p vectorcraft-ui-egui --all-targets -- -D warnings (Rust 1.99): clean.
  • cargo fmt --all -- --check: clean.
  • Checked by hand in a release build on Windows with a real double-click on "Hello world" and real typing: the Type tool was editing it with the caret at byte 6, where it was clicked, and typing X gave "Hello Xworld" in one "Typing" step. The fill and stroke were unchanged.

I didn't run the full cargo xtask ci (wasm step) here.

🤖 Generated with Claude Code

theironchef and others added 2 commits October 7, 2026 13:19
… typed

egui reports the character a key types, so Cmd+Shift+[ arrives as
Cmd+Shift+{ (], / likewise as }, ?) and Shift+` as the text ~, and these
default shortcuts never matched: Bring to Front, Send to Back, Search
Commands and the Curvature tool. Command chords now also take the
shifted character, single-key tool and command shortcuts also look up
Shift+<typed text>, and the Keyboard Shortcuts editor records such a
chord as its key (Cmd+Shift+], not Cmd+Shift+}), so conflicts show.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e caret there

The Selection tool's double-click on text only switched to the Type
tool, which then had nothing being edited, so typing went to the tool
shortcuts (X swapped the text's fill and stroke). After such a switch
the canvas passes the double-click on to the Type tool as a click, which
starts editing the type with the caret where it was clicked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bflatastic
bflatastic force-pushed the fix/double-click-type-caret branch from 4f985ed to 11799fa Compare October 7, 2026 06:30
@bflatastic
bflatastic merged commit 6a62dc5 into storytold:main Oct 7, 2026
@bflatastic

Copy link
Copy Markdown
Member

Thanks @theironchef, merged! I rebased it on main (both canvas tests kept next to the others) and added an "Editing type" line to the ROADMAP. Live check: a double-click on "Hello world" with the Selection tool switched to the Type tool with the caret at 6, and typing X gave "Hello Xworld" instead of swapping fill and stroke.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Double-clicking type with the Selection tool doesn't place a caret; typing then triggers shortcuts (X swaps fill/stroke)

2 participants