summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Héctor <hector@hecrj.dev>2024-12-02 20:13:02 +0100
committerLibravatar GitHub <noreply@github.com>2024-12-02 20:13:02 +0100
commit3b2a422d5d4bf0d21301338050637ce717cff5f7 (patch)
tree1fe346e980413ea4e7234af920302ef289ca2ecf
parent8295b231df3a0bf5fa53a69abcf4f77f4f935375 (diff)
parent713aa74f4cbfec6d27579e1700cbefc2630cd2f3 (diff)
downloadiced-3b2a422d5d4bf0d21301338050637ce717cff5f7.tar.gz
iced-3b2a422d5d4bf0d21301338050637ce717cff5f7.tar.bz2
iced-3b2a422d5d4bf0d21301338050637ce717cff5f7.zip
Merge pull request #2683 from T-256/master
Call `OnPress::get` only when button is pressed
-rw-r--r--widget/src/button.rs5
1 files changed, 2 insertions, 3 deletions
diff --git a/widget/src/button.rs b/widget/src/button.rs
index d1fa9302..a2f9945c 100644
--- a/widget/src/button.rs
+++ b/widget/src/button.rs
@@ -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();