From 55f4a4db74209ddfb6a67b3ed431b360807e039e Mon Sep 17 00:00:00 2001 From: pml68 Date: Thu, 10 Jul 2025 02:50:21 +0200 Subject: feat: make close-only dialogs closable via `Esc` or clicking the backdrop --- src/dialog.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/dialog.rs') diff --git a/src/dialog.rs b/src/dialog.rs index d5fdc14..3a79dd4 100644 --- a/src/dialog.rs +++ b/src/dialog.rs @@ -10,7 +10,7 @@ pub const UNSAVED_CHANGES_TITLE: &str = "Hold on for a sec!"; pub const WARNING_TITLE: &str = "Heads up!"; pub const ERROR_TITLE: &str = "Oops! Something went wrong."; -#[derive(Debug, Clone, Copy, Default)] +#[derive(Debug, Clone, Copy, Default, PartialEq)] pub enum Action { #[default] None, @@ -18,7 +18,7 @@ pub enum Action { UnsavedChanges(UnsavedChanges), } -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, PartialEq)] pub enum UnsavedChanges { New, Open, @@ -99,5 +99,9 @@ impl Dialog { self.action.into(), ) .title(&*self.title) + .on_press_maybe( + matches!(self.action, Action::Close) + .then_some(Message::CloseDialog), + ) } } -- cgit v1.2.3