Skip to content

Fix: Fixed Ctrl+A in the rename textbox #12050

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

Merged
merged 2 commits into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
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
16 changes: 5 additions & 11 deletions src/Files.App/Views/LayoutModes/ColumnViewBase.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ private void FileList_PreviewKeyUp(object sender, KeyRoutedEventArgs e)

protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
{
if (ParentShellPageInstance is null)
if (ParentShellPageInstance is null || IsRenamingItem)
return;

var ctrlPressed = InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Control).HasFlag(CoreVirtualKeyStates.Down);
Expand All @@ -266,15 +266,9 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv
var hotKey = new HotKey(Keys.A, KeyModifiers.Ctrl);

await commands[hotKey].ExecuteAsync();

return;
}

if (e.Key == VirtualKey.Enter && !e.KeyStatus.IsMenuKeyDown)
else if (e.Key == VirtualKey.Enter && !e.KeyStatus.IsMenuKeyDown)
{
if (IsRenamingItem)
return;

e.Handled = true;

if (IsItemSelected && SelectedItem.PrimaryItemAttribute == StorageItemTypes.Folder)
Expand All @@ -287,7 +281,7 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv
}
else if (e.Key == VirtualKey.Space)
{
if (!IsRenamingItem && !ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled)
if (!ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled)
e.Handled = true;
}
else if (e.KeyStatus.IsMenuKeyDown && (e.Key == VirtualKey.Left || e.Key == VirtualKey.Right || e.Key == VirtualKey.Up))
Expand All @@ -313,7 +307,7 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv
}
else if (e.Key == VirtualKey.Left) // Left arrow: select parent folder (previous column)
{
if (IsRenamingItem || (ParentShellPageInstance is not null && ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled))
if (ParentShellPageInstance is not null && ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled)
return;

var currentBladeIndex = (ParentShellPageInstance is ColumnShellPage associatedColumnShellPage) ? associatedColumnShellPage.ColumnParams.Column : 0;
Expand All @@ -324,7 +318,7 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv
}
else if (e.Key == VirtualKey.Right) // Right arrow: switch focus to next column
{
if (IsRenamingItem || (ParentShellPageInstance is not null && ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled))
if (ParentShellPageInstance is not null && ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled)
return;

var currentBladeIndex = (ParentShellPageInstance is ColumnShellPage associatedColumnShellPage) ? associatedColumnShellPage.ColumnParams.Column : 0;
Expand Down
14 changes: 4 additions & 10 deletions src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ protected override void EndRename(TextBox textBox)

protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
{
if (ParentShellPageInstance is null)
if (ParentShellPageInstance is null || IsRenamingItem)
return;

var ctrlPressed = InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Control).HasFlag(CoreVirtualKeyStates.Down);
Expand All @@ -326,15 +326,9 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv
var hotKey = new HotKey(Keys.A, KeyModifiers.Ctrl);

await commands[hotKey].ExecuteAsync();

return;
}

if (e.Key == VirtualKey.Enter && !e.KeyStatus.IsMenuKeyDown)
else if (e.Key == VirtualKey.Enter && !e.KeyStatus.IsMenuKeyDown)
{
if (IsRenamingItem)
return;

e.Handled = true;

if (ctrlPressed && !shiftPressed)
Expand All @@ -358,7 +352,7 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv
}
else if (e.Key == VirtualKey.Space)
{
if (!IsRenamingItem && !ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled)
if (!ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled)
e.Handled = true;
}
else if (e.KeyStatus.IsMenuKeyDown && (e.Key == VirtualKey.Left || e.Key == VirtualKey.Right || e.Key == VirtualKey.Up))
Expand All @@ -373,7 +367,7 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv
}
else if (e.Key == VirtualKey.Down)
{
if (!IsRenamingItem && isHeaderFocused && !ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled)
if (isHeaderFocused && !ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled)
{
var selectIndex = FileList.SelectedIndex < 0 ? 0 : FileList.SelectedIndex;
if (FileList.ContainerFromIndex(selectIndex) is ListViewItem item)
Expand Down
12 changes: 3 additions & 9 deletions src/Files.App/Views/LayoutModes/GridViewBrowser.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ protected override void EndRename(TextBox textBox)

protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
{
if (ParentShellPageInstance is null)
if (ParentShellPageInstance is null || IsRenamingItem)
return;

var ctrlPressed = InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Control).HasFlag(CoreVirtualKeyStates.Down);
Expand All @@ -269,15 +269,9 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv
var hotKey = new HotKey(Keys.A, KeyModifiers.Ctrl);

await commands[hotKey].ExecuteAsync();

return;
}

if (e.Key == VirtualKey.Enter && !isFooterFocused && !e.KeyStatus.IsMenuKeyDown)
else if (e.Key == VirtualKey.Enter && !isFooterFocused && !e.KeyStatus.IsMenuKeyDown)
{
if (IsRenamingItem)
return;

e.Handled = true;

if (ctrlPressed && !shiftPressed)
Expand All @@ -301,7 +295,7 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv
}
else if (e.Key == VirtualKey.Space)
{
if (!IsRenamingItem && !ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled)
if (!ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled)
e.Handled = true;
}
else if (e.KeyStatus.IsMenuKeyDown && (e.Key == VirtualKey.Left || e.Key == VirtualKey.Right || e.Key == VirtualKey.Up))
Expand Down