Repository: iced-rs/iced (language: rust)

Issue:
`on_press_with` always calls the closure
### Is your issue REALLY a bug?

- [X] My issue is indeed a bug!
- [X] I am not crazy! I will not fill out this form just to ask a question or request a feature. Pinky promise.

### Is there an existing issue for this?

- [X] I have searched the existing issues.

### Is this issue related to iced?

- [X] My hardware is compatible and my graphics drivers are up-to-date.

### What happened?

At below code, when click on each button, it will print both `foo` and `bar`.

```rs
use iced::widget::{button, column, text};

#[derive(Default)]
struct State {}

#[derive(Debug, Default, Clone)]
enum Message {
    #[default]
    Test,
}

fn main() -> iced::Result {
    iced::application("icedbug", |_: &mut State, _| {}, view).run()
}

fn view(_state: &State) -> iced::Element<Message> {
    column![
        button(text("foo")).on_press_with(|| {
            dbg!("foo");
            Message::Test
        }),
        button(text("bar")).on_press_with(|| {
            dbg!("bar");
            Message::Test
        }),
    ]
    .into()
}
```

### What is the expected behavior?

Call closure only when related button pressed.

### Version

crates.io release

### Operating System

Windows

### Do you have any log output?

`Cargo.toml`:

```toml
[package]
name = "icedbug"
version = "0.1.0"
edition = "2021"

[dependencies]
iced = { version = "0.13" }
```



Discussion / hints:

Fix patch:
diff --git a/widget/src/button.rs b/widget/src/button.rs
index d1fa93027a..a2f9945c19 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();


Test patch: