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 <noreply@anthropic.com>
This commit is contained in:
Dylan M. Taylor
2026-11-28 00:44:54 +00:00
co-authored by Claude Opus 5.5
parent 5ca353dfbc
commit 8d8cfc4d2a
+7 -13
View File
@@ -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;