diff --git a/crates/ui-contract/src/contract/steps/finish.rs b/crates/ui-contract/src/contract/steps/finish.rs index 0f1c20d66..877956f2f 100644 --- a/crates/ui-contract/src/contract/steps/finish.rs +++ b/crates/ui-contract/src/contract/steps/finish.rs @@ -14,7 +14,7 @@ use egui::{Context, Id, Response, Ui, Vec2}; /// `changed` is `value_changed` of the pass's events. pub(crate) fn before_finish(core: &mut CxCore<'_>, activated: bool, injected: Option, changed: bool) { let by_key = activated && core.activation.is_some_and(|activation| activation.by_key); - response::rewrite_clicks(&mut core.response, by_key || core.part_clicked, core.command.is_some()); + response::rewrite_clicks(&mut core.response, by_key || core.part_clicked, core.command.is_some() && activated); if changed { response::mark_changed(&mut core.response); } diff --git a/crates/ui-contract/src/runtime/egui/response.rs b/crates/ui-contract/src/runtime/egui/response.rs index 342292d53..70685a79f 100644 --- a/crates/ui-contract/src/runtime/egui/response.rs +++ b/crates/ui-contract/src/runtime/egui/response.rs @@ -150,13 +150,13 @@ pub(crate) fn press_flags(response: &mut Response, view: PressView) { /// Rewrites the click flags of the root's `Response` at step 17: egui's fake click on Enter, Space or AccessKit /// `Click` is cleared, and set again only when the pipeline activated the component by key or by an AccessKit click on a part. A command-bound -/// component reports no click, because the command fires instead. -pub(crate) fn rewrite_clicks(response: &mut Response, activated_by_key: bool, command_bound: bool) { +/// component reports no click on a pass where its command fired, because the command fires instead. +pub(crate) fn rewrite_clicks(response: &mut Response, activated_by_key: bool, command_fired: bool) { response.flags.remove(Flags::FAKE_PRIMARY_CLICKED); if activated_by_key { response.flags.insert(Flags::FAKE_PRIMARY_CLICKED); } - if command_bound { + if command_fired { response.flags.remove(Flags::CLICKED | Flags::FAKE_PRIMARY_CLICKED); } } diff --git a/crates/ui-widgets/src/buttons/stories.rs b/crates/ui-widgets/src/buttons/stories.rs index 738d0cf50..e52dcb9a5 100644 --- a/crates/ui-widgets/src/buttons/stories.rs +++ b/crates/ui-widgets/src/buttons/stories.rs @@ -233,8 +233,10 @@ fn click_and_stay(fixture: &mut Fixture) { #[story(ToggleButton<'static>, covers = [], drive = Drive::Custom(click_and_stay), title = "Clicked under the pointer")] fn toggle_button_clicked_under_pointer(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { let shown = ToggleButton::new("Snap to grid", Bind::bound(data.value("snap_hover", false))).icon(IconId::new("eye")).show(ui); - *data.value("clicked_over", false) = shown.hover.clicked; - shown.into() + // The hold is the component's own state, which a measuring run does not carry: the story words it in its readout, + // not in its data, which the purity probe compares. + let clicked = shown.hover.clicked; + StoryOutput::from(shown).readout(if clicked { "Clicked, pointer still over" } else { "Not clicked" }) } #[story(ToggleButton<'static>, covers = [Mixed], drive = Drive::Never)]