diff options
| author | pml68 <contact@pml68.dev> | 2025-07-06 00:46:25 +0200 |
|---|---|---|
| committer | pml68 <contact@pml68.dev> | 2025-07-06 00:46:25 +0200 |
| commit | d7e57376ad3d4310e11f62dbf00c554f5994515c (patch) | |
| tree | 6906ae4c93d62beec45f74c580104d13051777d4 | |
| parent | feat: add horizontal and vertical alignment options (diff) | |
| download | iced_dialog-d7e57376ad3d4310e11f62dbf00c554f5994515c.tar.gz | |
feat: add `on_press_maybe` method
| -rw-r--r-- | src/dialog.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/dialog.rs b/src/dialog.rs index 51a6801..732f8e0 100644 --- a/src/dialog.rs +++ b/src/dialog.rs @@ -141,6 +141,20 @@ where self } + /// Sets the message that will be produced when the [`Dialog`]'s backdrop is pressed, if `Some`. + pub fn on_press_maybe(mut self, on_press: Option<Message>) -> Self + where + Message: Clone, + { + self.on_press = if let Some(on_press) = on_press { + Some(Box::new(move || on_press.clone())) + } else { + None + }; + + self + } + /// Sets the [`Dialog`]'s width. pub fn width(mut self, width: impl Into<Length>) -> Self { self.width = width.into(); |
