From 391fb9a21ad1ea0117b95b9b18fdcf10f7dd7dcc Mon Sep 17 00:00:00 2001 From: Filippo Ferrario Date: Thu, 16 Mar 2023 14:01:13 +0100 Subject: [PATCH] Feature: Only open single tab if user holds down ctrl + t --- src/Files.App/Views/MainPage.xaml.cs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/Files.App/Views/MainPage.xaml.cs b/src/Files.App/Views/MainPage.xaml.cs index 096228e491b6..36038a874db0 100644 --- a/src/Files.App/Views/MainPage.xaml.cs +++ b/src/Files.App/Views/MainPage.xaml.cs @@ -59,6 +59,8 @@ public MainPageViewModel ViewModel /// private bool draggingPreviewPane; + private bool keyReleased = true; + public SidebarViewModel SidebarAdaptiveViewModel = new SidebarViewModel(); public OngoingTasksViewModel OngoingTasksViewModel => App.OngoingTasksViewModel; @@ -235,20 +237,19 @@ protected override async void OnPreviewKeyDown(KeyRoutedEventArgs e) default: // break for natives hotkeys in textbox (cut/copy/paste/selectAll/cancel) bool isTextBox = e.OriginalSource is DependencyObject source && source.FindAscendantOrSelf() is not null; - if (isTextBox) + if (isTextBox && + currentModifiers is VirtualKeyModifiers.Control && + e.Key is VirtualKey.X or VirtualKey.C or VirtualKey.V or VirtualKey.A or VirtualKey.Z) { - if (currentModifiers is VirtualKeyModifiers.Control && - e.Key is VirtualKey.X or VirtualKey.C or VirtualKey.V or VirtualKey.A or VirtualKey.Z) - { - break; - } + break; } // execute command for hotkey var hotKey = new HotKey(e.Key, currentModifiers); var command = Commands[hotKey]; - if (command.Code is not CommandCodes.None) + if (command.Code is not CommandCodes.None && keyReleased) { + keyReleased = false; e.Handled = command.IsExecutable; await command.ExecuteAsync(); } @@ -261,6 +262,10 @@ protected override void OnPreviewKeyUp(KeyRoutedEventArgs e) switch (e.Key) { + case VirtualKey.LeftWindows: + case VirtualKey.RightWindows: + currentModifiers |= VirtualKeyModifiers.Windows; + break; case VirtualKey.Menu: currentModifiers &= ~VirtualKeyModifiers.Menu; break; @@ -270,6 +275,9 @@ protected override void OnPreviewKeyUp(KeyRoutedEventArgs e) case VirtualKey.Shift: currentModifiers &= ~VirtualKeyModifiers.Shift; break; + default: + keyReleased = true; + break; } }