Finish Hand panning before switching to a pen eraser

This commit is contained in:
Codex committed 2026-11-30 12:50:23 +01:00
1 parent f4e2f5f4c6
commit adece8e918
2 files changed
+20

No files matched your search

+19
View File
@@ -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]
@@ -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)
{