Skip to content

Commit

Permalink
Merge pull request #2683 from T-256/master
Browse files Browse the repository at this point in the history
Call `OnPress::get` only when button is pressed
  • Loading branch information
hecrj authored Dec 2, 2024
2 parents 8295b23 + 713aa74 commit 3b2a422
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions widget/src/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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();
Expand Down

0 comments on commit 3b2a422

Please sign in to comment.