From 8d8cfc4d2ae236f161862e88989b7c4a6c2f0dc9 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sat, 28 Nov 2026 00:44:54 +0000 Subject: [PATCH] Ribbon scroll case: the arrow click is injected ahead of the canvas click The window holds real input until the injected batch has run, so the arrow's press now goes into the same batch as the canvas click, followed by a pointer rest on the arrow. The rest holds the queue until the row has scrolled, so the canvas click is still queued when the target changes and is withdrawn, as in the other target-change cases. A click whose first step has already run is delivered whole. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/tests.rs | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/crates/ui-egui/src/tests.rs b/crates/ui-egui/src/tests.rs index dec6c0e58..45a43a7e6 100644 --- a/crates/ui-egui/src/tests.rs +++ b/crates/ui-egui/src/tests.rs @@ -1410,9 +1410,13 @@ fn input_target_changes_retract_a_queued_click() { let target = h.state().input_target(&ctx); let slide = h.state().slide_rect().unwrap(); let point = slide.min + slide.size() * 0.8; + // The window holds real input until the injected batch has run, so the arrow's press goes ahead of the click. + // The pointer rests on the arrow until the row has moved: a click whose first step ran is delivered whole. if case == "scroll" { let arrow = ribbon_arrow(&h); - WindowHost::of(&ctx).inject_move(egui::ViewportId::ROOT, arrow, craft::keymap::Mods::default(), 0.0); + let host = WindowHost::of(&ctx); + host.inject_click(egui::ViewportId::ROOT, arrow, craft::behavior::PointerButton::Primary, 1, craft::keymap::Mods::default(), false); + host.inject_move(egui::ViewportId::ROOT, arrow, craft::keymap::Mods::default(), 0.25); } WindowHost::of(&ctx).inject_click( egui::ViewportId::ROOT, @@ -1444,18 +1448,8 @@ fn input_target_changes_retract_a_queued_click() { "collapse" => h.state_mut().ui.ribbon_collapsed = true, "scroll" => { let before = crate::ribbon::scroll_position(h.state(), &ctx); - let at = ribbon_arrow(&h); - h.input_mut().events.push(egui::Event::PointerMoved(at)); - for pressed in [true, false] { - h.input_mut().events.push(egui::Event::PointerButton { - pos: at, - button: egui::PointerButton::Primary, - pressed, - modifiers: egui::Modifiers::NONE, - }); - } - // The press waits behind the injected batch, so the row may move a frame later. - for _ in 0..4 { + // The arrow's injected move, press and release each take a pass of their own. + for _ in 0..6 { h.run_steps(1); if crate::ribbon::scroll_position(h.state(), &ctx) != before { break;