summaryrefslogtreecommitdiffstats
path: root/widget/src
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-06-06 16:18:20 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-06-06 16:18:20 +0200
commit5b5000e3ae9789cf1d83cecd08f4d0cedc16d788 (patch)
treed7f0851d872ec8fbff733fb9ab804cdb3b55c4e0 /widget/src
parent5324928044cba800454b1861eb9999038bc28c2e (diff)
downloadiced-5b5000e3ae9789cf1d83cecd08f4d0cedc16d788.tar.gz
iced-5b5000e3ae9789cf1d83cecd08f4d0cedc16d788.tar.bz2
iced-5b5000e3ae9789cf1d83cecd08f4d0cedc16d788.zip
Introduce `on_press_maybe` helper for `Button`
Diffstat (limited to 'widget/src')
-rw-r--r--widget/src/button.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/widget/src/button.rs b/widget/src/button.rs
index 70fed1d5..c656142c 100644
--- a/widget/src/button.rs
+++ b/widget/src/button.rs
@@ -102,8 +102,17 @@ where
/// Sets the message that will be produced when the [`Button`] is pressed.
///
/// Unless `on_press` is called, the [`Button`] will be disabled.
- pub fn on_press(mut self, msg: Message) -> Self {
- self.on_press = Some(msg);
+ pub fn on_press(mut self, on_press: Message) -> Self {
+ self.on_press = Some(on_press);
+ self
+ }
+
+ /// Sets the message that will be produced when the [`Button`] is pressed,
+ /// if `Some`.
+ ///
+ /// If `None`, the [`Button`] will be disabled.
+ pub fn on_press_maybe(mut self, on_press: Option<Message>) -> Self {
+ self.on_press = on_press;
self
}