Merge pull request #2683 from T-256/master

Call `OnPress::get` only when button is pressed
This commit is contained in:
Héctor 2024-12-02 20:13:02 +01:00 committed by GitHub
commit 3b2a422d5d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -315,8 +315,7 @@ where
}
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
| Event::Touch(touch::Event::FingerLifted { .. }) => {
if let Some(on_press) = self.on_press.as_ref().map(OnPress::get)
{
if let Some(on_press) = &self.on_press {
let state = tree.state.downcast_mut::<State>();
if state.is_pressed {
@ -325,7 +324,7 @@ where
let bounds = layout.bounds();
if cursor.is_over(bounds) {
shell.publish(on_press);
shell.publish(on_press.get());
}
shell.capture_event();