Repository navigation
Canvas: a click just outside the canvas doesn't reach the tools - #233
Merged
Merged
Conversation
egui counts a press a few pixels outside the canvas as hovering it (its interaction radius), but the canvas only takes pointer positions inside its rect, so such a press fell back to the canvas's centre: a click just below the document tabs or beside the panels selected, typed or drew in the middle of the view. Presses, and middle-button pans, now start only on the canvas itself. Fixes storytold#232. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
Thanks, merged! Good catch with real mouse input: a press inside egui's interaction radius falling back to the view's centre is exactly the kind of bug synthetic tests miss. I checked it against the canvas context menu that landed in #229 (right-click and dismiss), and the two work together. The full |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #232.
Problem: egui reports the canvas response as hovered for a pointer a few pixels outside its rect (its interaction radius). But
handle_input(crates/ui-egui/src/canvas.rs) only takes pointer positions inside the rect (hover), and for a press there it fell back torect.center().So a click in the band around the canvas reached the active tool at the centre of the view. That band includes just below the document tabs, beside the panel strip and above the hint bar. With the Selection tool the click selected whatever was in the middle, with the Type tool it started text there, and drawing tools drew from there. The middle-button pan had the same fallback.
Change: a primary press, and a middle-button pan, now start only when the pointer is on the canvas itself:
&& let Some(p) = hoverin place ofhover.unwrap_or(rect.center()). A press in the band does nothing, as on any other empty part of the window.Tests
canvas::tests::a_click_just_outside_the_canvas_does_not_reach_the_tool. It lays the canvas out under a 40-point bar, as under the document tabs, with a square in the middle of the view. A click 2 px above the canvas leaves nothing selected, and a click at the canvas centre selects the square.main("a click above the canvas selected [NodeId(2)]") and passes with this change.cargo test -p vectorcraft-ui-egui: 526 passed.cargo clippy -p vectorcraft-ui-egui --all-targets -- -D warnings(Rust 1.99): clean.cargo fmt --all -- --check: clean.I found this by driving a release build on Windows with real mouse input. I didn't run the full
cargo xtask ci(wasm step) here.🤖 Generated with Claude Code