From adece8e9185c5330c0a88a2c3d396b5cfd12992f Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 12:46:11 +0100 Subject: [PATCH] Finish Hand panning before switching to a pen eraser --- crates/ui-egui/src/canvas/tests.rs | 19 +++++++++++++++++++ crates/ui-egui/src/canvas/tool_adapter.rs | 1 + 2 files changed, 20 insertions(+) diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index ae6956a288..5e7e563dc7 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -4835,6 +4835,25 @@ fn a_flip_during_a_press_waits_for_the_release() { assert_eq!(app.session.tool_id(), "eraser", "the frame after the release"); } +/// A selected Hand tracks its drag in the framework, outside the document tool's grab. +#[test] +fn turning_the_pen_during_a_hand_drag_waits_for_release() { + let (mut app, stylus, ctx) = pen_app(); + app.select_tool("hand"); + let at = app.canvas_view().unwrap().rect.center(); + let to = at + egui::vec2(30.0, 20.0); + let button = |pos, pressed| egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }; + stylus.set(tip(0.5)); + frame(&mut app, &ctx, vec![egui::Event::PointerMoved(at), button(at, true)]); + stylus.set(eraser_end(0.5)); + frame(&mut app, &ctx, vec![egui::Event::PointerMoved(to)]); + assert_eq!(app.session.tool_id(), "hand"); + frame(&mut app, &ctx, vec![button(to, false)]); + assert_eq!(app.session.tool_id(), "hand"); + frame(&mut app, &ctx, vec![]); + assert_eq!(app.session.tool_id(), "eraser"); +} + /// #764: a tool chosen while the eraser end stands in (the toolbar and shortcuts call /// `select_tool`; menus and MCP run `tool.select`) stays when the tip comes back. #[test] diff --git a/crates/ui-egui/src/canvas/tool_adapter.rs b/crates/ui-egui/src/canvas/tool_adapter.rs index 6ebdd54af4..cc2750f2a4 100644 --- a/crates/ui-egui/src/canvas/tool_adapter.rs +++ b/crates/ui-egui/src/canvas/tool_adapter.rs @@ -629,6 +629,7 @@ pub(crate) fn run(app: &mut VectorcraftApp, ui: &mut Ui, pass: &ToolPass) -> Too // the release, and a pointer over another window for the pointer to come in. if ui.ctx().current_pass_index() == 0 && app.canvas.grab.is_none() + && !ToolHost::in_gesture(ui.ctx(), pass.id) && ui.input(|i| i.pointer.has_pointer()) && crate::stylus::sync_eraser_tool(app) {