From 84d782c85b43477c3db7b4904e0fa7bfbd4fa53c Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 25 Oct 2026 14:19:01 -0700 Subject: [PATCH 1/2] M5: controller buttons wait while the link notice shows A controller button pressed while the notice before a website link shows no longer plays the prototype's gamepad triggers, as keys do not. Buttons play again once the notice closes. --- crates/ui-egui/src/present.rs | 2 ++ crates/ui-egui/src/present_links_tests.rs | 28 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/crates/ui-egui/src/present.rs b/crates/ui-egui/src/present.rs index bbaae4b64..b5c7eb0fb 100644 --- a/crates/ui-egui/src/present.rs +++ b/crates/ui-egui/src/present.rs @@ -2506,7 +2506,9 @@ fn input(p: &mut Presenter, ctx: &egui::Context, l: &Layout, over_area: bool, ke ) }); let keys = if keys_on { keys } else { Vec::new() }; + // Controller buttons pressed while a link notice shows are dropped, as keys are. let pads = std::mem::take(&mut p.pads); + let pads = if p.link_notice.is_none() { pads } else { Vec::new() }; // A transition a drag started follows the pointer while it stays down, then plays on from there. if let Some(a) = p.anim.as_mut() && let Some((from, dir, len)) = a.follow diff --git a/crates/ui-egui/src/present_links_tests.rs b/crates/ui-egui/src/present_links_tests.rs index 31a6b2bc8..a2b571aff 100644 --- a/crates/ui-egui/src/present_links_tests.rs +++ b/crates/ui-egui/src/present_links_tests.rs @@ -162,6 +162,34 @@ fn the_presenter_keys_wait_while_the_notice_shows() { assert_eq!(notice(&u), "https://example.com/a"); } +#[test] +fn the_prototype_takes_no_controller_buttons_while_the_notice_shows() { + let mut s = Session::new(); + let a = id(&ex(&mut s, "frame.create", json!({"x": 0, "y": 0, "width": 300, "height": 400, "name": "A"}))); + let b = id(&ex(&mut s, "frame.create", json!({"x": 400, "y": 0, "width": 300, "height": 400, "name": "B"}))); + let layer = id(&ex(&mut s, "shape.rectangle", json!({"x": 10, "y": 10, "width": 30, "height": 30, "parent": a}))); + let link = json!({"type": "openUrl", "url": "https://example.com/a"}); + ex(&mut s, "proto.interaction.add", json!({"id": layer, "trigger": {"type": "afterDelay", "ms": 100}, "action": link})); + let to_b = json!({"type": "navigate", "dest": b}); + ex(&mut s, "proto.interaction.add", json!({"id": a, "trigger": {"type": "keyPress", "key": "Gamepad A"}, "action": to_b})); + let mut u = Harness::new(s); + u.app.services = Box::new(Opened::default()); + u.ctx.enable_accesskit(); + u.run("proto.present", json!({"start": a})); + u.frames(40, Vec::new); + assert_eq!(notice(&u), "https://example.com/a"); + let ctx = u.ctx.clone(); + crate::control::handle(&mut u.app, &ctx, "ui.input", &json!({"events": [{"gamepad": "A"}]})).unwrap(); + u.frames(2, Vec::new); + assert_eq!(u.app.inspect()["presenter"]["current"], json!(a), "the Gamepad A trigger did not run"); + assert_eq!(notice(&u), "https://example.com/a"); + click(&mut u, "Cancel"); + assert!(notice(&u).is_null()); + crate::control::handle(&mut u.app, &ctx, "ui.input", &json!({"events": [{"gamepad": "A"}]})).unwrap(); + u.frames(2, Vec::new); + assert_eq!(u.app.inspect()["presenter"]["current"], json!(b), "the button plays once the notice closes"); +} + #[test] fn dont_show_this_again_is_saved_with_the_preferences() { let (mut u, seen) = presented("https://example.com/a", false); From 7820825ea10bd2ab67af1a12280d4e12b91aa70e Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 25 Oct 2026 17:09:48 -0700 Subject: [PATCH 2/2] M5: controller buttons pressed with no frame shown are dropped A controller button pressed while the player has no frame to show, for example after the frame is deleted, no longer plays the prototype's gamepad trigger once the frame comes back. --- crates/ui-egui/src/present.rs | 5 +++++ crates/ui-egui/src/present_tests.rs | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/crates/ui-egui/src/present.rs b/crates/ui-egui/src/present.rs index b5c7eb0fb..b1947a68a 100644 --- a/crates/ui-egui/src/present.rs +++ b/crates/ui-egui/src/present.rs @@ -2198,6 +2198,9 @@ fn player(p: &mut Presenter, ui: &mut Ui, rect: Rect, now: f64, chrome: Chrome) p.restart(p.start, now); } if p.doc.as_ref().is_none_or(|d| !d.contains(p.current)) { + // Controller buttons pressed with no frame to show are dropped, as they are while a link + // notice shows. + p.pads.clear(); if !chrome.pane { return Some(BarAction::Close); } @@ -2228,6 +2231,8 @@ fn player(p: &mut Presenter, ui: &mut Ui, rect: Rect, now: f64, chrome: Chrome) // the prototype takes neither keys nor the pointer (Escape there cancels the notice). let keys = chrome.keys && p.link_notice.is_none() && (!chrome.pane || over); input(p, &ctx, &l, over && p.link_notice.is_none(), keys, chrome.pane, now); + } else { + p.pads.clear(); } let Some(l) = layout(p, area, chrome) else { return action }; p.shown = Some((p.current, l.place, l.clip.intersect(area))); diff --git a/crates/ui-egui/src/present_tests.rs b/crates/ui-egui/src/present_tests.rs index 937299223..4a3819c09 100644 --- a/crates/ui-egui/src/present_tests.rs +++ b/crates/ui-egui/src/present_tests.rs @@ -137,6 +137,26 @@ fn preview_pane_opens_follows_edits_and_the_selection() { assert!(u.app.ui.preview.is_none()); } +/// A controller button pressed while the pane has no frame to show is dropped, and does not play +/// once the frame comes back. +#[test] +fn controller_buttons_pressed_with_no_frame_shown_are_dropped() { + let (mut u, a, b, _) = setup(); + let to_b = json!({"type": "navigate", "dest": b}); + u.run("proto.interaction.add", json!({"id": a, "trigger": {"type": "keyPress", "key": "Gamepad A"}, "action": to_b})); + u.run("proto.preview", json!({"start": a})); + u.run("edit.delete", json!({"ids": [a]})); + let ctx = u.ctx.clone(); + crate::control::handle(&mut u.app, &ctx, "ui.input", &json!({"events": [{"gamepad": "A"}]})).unwrap(); + u.frames(2, Vec::new); + u.run("edit.undo", json!({})); + u.frames(2, Vec::new); + assert_eq!(u.preview()["current"], json!(a), "the button pressed with no frame shown did not play"); + crate::control::handle(&mut u.app, &ctx, "ui.input", &json!({"events": [{"gamepad": "A"}]})).unwrap(); + u.frames(2, Vec::new); + assert_eq!(u.preview()["current"], json!(b), "a button pressed with the frame shown plays"); +} + /// Asserts the preview's device viewport and scroll range, wheel and drag scrolling, the /// end clamp with spring-back, and that navigation resets scroll to the top. #[test]