fix(segmented_button): close context menu when clicked outside

This commit is contained in:
Jason Hansen 2024-12-31 16:37:04 -07:00 committed by GitHub
parent 3f2ba11d56
commit 51ede4bce6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 5 deletions

View file

@ -579,7 +579,7 @@ where
.merge(menu_status)
}
Mouse(ButtonReleased(Left)) | Touch(FingerLifted { .. }) => {
Mouse(ButtonReleased(_)) | Touch(FingerLifted { .. }) => {
let state = self.tree.state.downcast_mut::<MenuBarState>();
state.pressed = false;
@ -596,7 +596,13 @@ where
.iter()
.any(|ms| ms.menu_bounds.check_bounds.contains(overlay_cursor));
if self.close_condition.click_inside && is_inside {
if self.close_condition.click_inside
&& is_inside
&& matches!(
event,
Mouse(ButtonReleased(Left)) | Touch(FingerLifted { .. })
)
{
state.reset();
return Captured;
}