From d7e57376ad3d4310e11f62dbf00c554f5994515c Mon Sep 17 00:00:00 2001 From: pml68 Date: Sun, 6 Jul 2025 00:46:25 +0200 Subject: feat: add `on_press_maybe` method --- src/dialog.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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) -> 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) -> Self { self.width = width.into(); -- cgit v1.2.3