From ebb74da8b39b92c7621d201a687bc3e5efd40928 Mon Sep 17 00:00:00 2001 From: DB P Date: Fri, 30 May 2025 13:37:50 +0900 Subject: [PATCH] Refactor key press handling in MessageBoxEx to improve result assignment logic --- Flow.Launcher/MessageBoxEx.xaml.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Flow.Launcher/MessageBoxEx.xaml.cs b/Flow.Launcher/MessageBoxEx.xaml.cs index c084b5149..510d14b89 100644 --- a/Flow.Launcher/MessageBoxEx.xaml.cs +++ b/Flow.Launcher/MessageBoxEx.xaml.cs @@ -159,12 +159,19 @@ namespace Flow.Launcher private void KeyEsc_OnPress(object sender, ExecutedRoutedEventArgs e) { - if (_button == MessageBoxButton.YesNo) - return; - else if (_button == MessageBoxButton.OK) - _result = MessageBoxResult.OK; - else - _result = MessageBoxResult.Cancel; + switch (_button) + { + case MessageBoxButton.OK: + _result = MessageBoxResult.None; + break; + case MessageBoxButton.OKCancel: + case MessageBoxButton.YesNoCancel: + _result = MessageBoxResult.Cancel; + break; + case MessageBoxButton.YesNo: + _result = MessageBoxResult.No; + break; + } DialogResult = false; Close(); }