aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpml68 <contact@pml68.dev>2025-07-06 00:46:25 +0200
committerpml68 <contact@pml68.dev>2025-07-06 00:46:25 +0200
commitd7e57376ad3d4310e11f62dbf00c554f5994515c (patch)
tree6906ae4c93d62beec45f74c580104d13051777d4
parentfeat: add horizontal and vertical alignment options (diff)
downloadiced_dialog-d7e57376ad3d4310e11f62dbf00c554f5994515c.tar.gz
feat: add `on_press_maybe` method
-rw-r--r--src/dialog.rs14
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();