From 7f6caca0f857a06c7e3b6078efaa05cf1512aedf Mon Sep 17 00:00:00 2001 From: Aleksander Date: Wed, 22 Jul 2026 22:23:44 +0200 Subject: [PATCH] wgui: MouseCancel event couldn't propagate all the way down (Closes #588) --- wgui/src/components/button.rs | 8 ++++---- wgui/src/layout.rs | 1 + wgui/src/widget/mod.rs | 6 +++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/wgui/src/components/button.rs b/wgui/src/components/button.rs index 9d64ac86..19808d21 100644 --- a/wgui/src/components/button.rs +++ b/wgui/src/components/button.rs @@ -508,11 +508,11 @@ fn register_event_mouse_release( state.sticky_down = !state.sticky_down; } - common.alterables.trigger_haptics(); - common.alterables.play_sound(WguiSoundType::ButtonRelease); - common.alterables.mark_redraw(); - if state.down { + common.alterables.trigger_haptics(); + common.alterables.play_sound(WguiSoundType::ButtonRelease); + common.alterables.mark_redraw(); + state.down = false; if state.hovered { anim_hover( diff --git a/wgui/src/layout.rs b/wgui/src/layout.rs index e408bded..8984261c 100644 --- a/wgui/src/layout.rs +++ b/wgui/src/layout.rs @@ -471,6 +471,7 @@ impl Layout { &mut self.get_event_params(l, node_id, style, alterables), widget_id, event, + event_result, )?; if res_priority.can_propagate() { diff --git a/wgui/src/widget/mod.rs b/wgui/src/widget/mod.rs index 2f888712..3236cff6 100644 --- a/wgui/src/widget/mod.rs +++ b/wgui/src/widget/mod.rs @@ -561,13 +561,17 @@ impl WidgetState { } // this is called before calling children of this widget - pub fn process_event_priority( + pub fn process_event_priority<'a>( &mut self, params: &mut EventParams, widget_id: WidgetID, event: &Event, + event_result: &'a mut EventResult, ) -> anyhow::Result { match &event { + Event::MouseCancel => { + *event_result = EventResult::Pass; + } Event::MouseUp(_e) => { if self.data.swipe_running { self.data.swipe_running = false;