diff --git a/src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs b/src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs index 8e93fd76628f..678956fec212 100644 --- a/src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs +++ b/src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs @@ -256,7 +256,7 @@ protected virtual void StartRenameItem(string itemNameTextBox) textBox.Focus(FocusState.Pointer); textBox.LostFocus += RenameTextBox_LostFocus; - textBox.KeyDown += RenameTextBox_KeyDown; + textBox.PreviewKeyDown += RenameTextBox_KeyDown; int selectedTextLength = SelectedItem.Name.Length; @@ -321,6 +321,16 @@ protected async void RenameTextBox_KeyDown(object sender, KeyRoutedEventArgs e) case VirtualKey.Right: e.Handled = (textBox.SelectionStart + textBox.SelectionLength) == textBox.Text.Length; break; + case VirtualKey.Home: + if (!isShiftPressed) + textBox.SelectionStart = 0; + e.Handled = true; + break; + case VirtualKey.End: + if (!isShiftPressed) + textBox.SelectionStart = textBox.Text.Length; + e.Handled = true; + break; case VirtualKey.Tab: textBox.LostFocus -= RenameTextBox_LostFocus; diff --git a/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs index 145334ba2356..0db9f53edfed 100644 --- a/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs @@ -217,7 +217,7 @@ protected override void EndRename(TextBox textBox) if (textBox is not null) { textBox!.LostFocus -= RenameTextBox_LostFocus; - textBox.KeyDown -= RenameTextBox_KeyDown; + textBox.PreviewKeyDown -= RenameTextBox_KeyDown; } if (textBox is not null && textBox.Parent is not null) diff --git a/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs index 625deb606b17..0bd0afbbf7b3 100644 --- a/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs @@ -374,7 +374,7 @@ protected override void EndRename(TextBox textBox) if (textBox is not null) { textBox!.LostFocus -= RenameTextBox_LostFocus; - textBox.KeyDown -= RenameTextBox_KeyDown; + textBox.PreviewKeyDown -= RenameTextBox_KeyDown; } FileNameTeachingTip.IsOpen = false; diff --git a/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs index 6455b3bfb919..552863fb6175 100644 --- a/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs @@ -353,7 +353,7 @@ override public void StartRenameItem() textBox.Focus(FocusState.Pointer); textBox.LostFocus += RenameTextBox_LostFocus; - textBox.KeyDown += RenameTextBox_KeyDown; + textBox.PreviewKeyDown += RenameTextBox_KeyDown; int selectedTextLength = RenamingItem.Name.Length; if (!RenamingItem.IsShortcut && UserSettingsService.FoldersSettingsService.ShowFileExtensions) @@ -408,7 +408,7 @@ protected override void EndRename(TextBox textBox) if (textBox is not null) { textBox.LostFocus -= RenameTextBox_LostFocus; - textBox.KeyDown -= RenameTextBox_KeyDown; + textBox.PreviewKeyDown -= RenameTextBox_KeyDown; } FileNameTeachingTip.IsOpen = false;