Call OnPress::get only when button is pressed

This commit is contained in:
T-256 2024-12-02 20:52:48 +03:30 committed by Héctor Ramón Jiménez
parent 8295b231df
commit 2cab4e6ddb
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -315,7 +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>();
@ -325,7 +325,7 @@ where
let bounds = layout.bounds();
if cursor.is_over(bounds) {
shell.publish(on_press);
shell.publish(on_press.get());
}
shell.capture_event();