From 7c506dceb68fae7e077f0631fd610ac36e34b355 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Thu, 27 Aug 2020 17:09:18 -0700 Subject: [PATCH] Add Ctrl+Enter as a way to close the LVTable edit dialog When editing local variables, the data grid generally has the input focus, so hitting Enter doesn't close the dialog. Rather than play games with the focus, just take Ctrl+Enter as a shortcut to close the dialog (same as notes and long comments). (I found myself hitting Ctrl+Enter automatically, and being annoyed when it didn't work, so I figured I'd make it official.) --- SourceGen/WpfGui/EditLocalVariableTable.xaml | 3 ++- SourceGen/WpfGui/EditLocalVariableTable.xaml.cs | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/SourceGen/WpfGui/EditLocalVariableTable.xaml b/SourceGen/WpfGui/EditLocalVariableTable.xaml index 471cdf7..81fde37 100644 --- a/SourceGen/WpfGui/EditLocalVariableTable.xaml +++ b/SourceGen/WpfGui/EditLocalVariableTable.xaml @@ -25,7 +25,8 @@ limitations under the License. Title="Edit Local Variable Table" SizeToContent="WidthAndHeight" ResizeMode="NoResize" ShowInTaskbar="False" WindowStartupLocation="CenterOwner" - Loaded="Window_Loaded"> + Loaded="Window_Loaded" + PreviewKeyDown="Window_KeyEventHandler"> Are you sure you want to delete the entire table? diff --git a/SourceGen/WpfGui/EditLocalVariableTable.xaml.cs b/SourceGen/WpfGui/EditLocalVariableTable.xaml.cs index a94ddcf..e7f66f4 100644 --- a/SourceGen/WpfGui/EditLocalVariableTable.xaml.cs +++ b/SourceGen/WpfGui/EditLocalVariableTable.xaml.cs @@ -274,6 +274,12 @@ namespace SourceGen.WpfGui { DialogResult = true; } + private void Window_KeyEventHandler(object sender, KeyEventArgs e) { + if (e.Key == Key.Return && Keyboard.Modifiers.HasFlag(ModifierKeys.Control)) { + OkButton_Click(null, null); + } + } + private void DeleteTableButton_Click(object sender, RoutedEventArgs e) { MessageBoxResult result = MessageBox.Show((string)FindResource("str_ConfirmDelete"), (string)FindResource("str_ConfirmDeleteCaption"),