Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Only open single tab if user holds down ctrl + t #11743

Merged
merged 1 commit into from
Mar 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions src/Files.App/Views/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public MainPageViewModel ViewModel
/// </summary>
private bool draggingPreviewPane;

private bool keyReleased = true;

public SidebarViewModel SidebarAdaptiveViewModel = new SidebarViewModel();

public OngoingTasksViewModel OngoingTasksViewModel => App.OngoingTasksViewModel;
Expand Down Expand Up @@ -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<TextBox>() 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();
}
Expand All @@ -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;
Expand All @@ -270,6 +275,9 @@ protected override void OnPreviewKeyUp(KeyRoutedEventArgs e)
case VirtualKey.Shift:
currentModifiers &= ~VirtualKeyModifiers.Shift;
break;
default:
keyReleased = true;
break;
}
}

Expand Down