Skip to content
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
2 changes: 1 addition & 1 deletion src/Files.App/UserControls/PathBreadcrumb.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
IsItemClickEnabled="True"
ItemTemplateSelector="{StaticResource PathBreadcrumbItemSelector}"
ItemsSource="{x:Bind ViewModel.PathComponents, Mode=OneWay}"
KeyDown="PathBoxItem_KeyDown"
PreviewKeyDown="PathBoxItem_PreviewKeyDown"
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.HorizontalScrollMode="Enabled"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/UserControls/PathBreadcrumb.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ private void PathBoxItem_PointerPressed(object sender, PointerRoutedEventArgs e)
ViewModel.PathBoxItem_PointerPressed(sender, e);
}

private void PathBoxItem_KeyDown(object sender, KeyRoutedEventArgs e)
private void PathBoxItem_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
{
ViewModel.PathBoxItem_KeyDown(sender, e);
ViewModel.PathBoxItem_PreviewKeyDown(sender, e);
}
}
}
30 changes: 24 additions & 6 deletions src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -525,14 +525,32 @@ await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(async () =>
});
}

public void PathBoxItem_KeyDown(object sender, KeyRoutedEventArgs e)
public void PathBoxItem_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
{
if (e.Key == Windows.System.VirtualKey.Down)
switch (e.Key)
{
var item = e.OriginalSource as ListViewItem;
var button = item?.FindDescendant<Button>();
button?.Flyout.ShowAt(button);
e.Handled = true;
case Windows.System.VirtualKey.Down:
{
var item = e.OriginalSource as ListViewItem;
var button = item?.FindDescendant<Button>();
button?.Flyout.ShowAt(button);
e.Handled = true;
break;
}
case Windows.System.VirtualKey.Space:
case Windows.System.VirtualKey.Enter:
{
var item = e.OriginalSource as ListViewItem;
var path = (item?.Content as PathBoxItem)?.Path;
if (path == PathControlDisplayText)
return;
ToolbarPathItemInvoked?.Invoke(this, new PathNavigationEventArgs()
{
ItemPath = path
});
e.Handled = true;
break;
}
}
}

Expand Down
8 changes: 7 additions & 1 deletion src/Files.App/Views/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,19 @@ private async Task OnPreviewKeyDownAsync(KeyRoutedEventArgs e)
default:
var currentModifiers = HotKeyHelpers.GetCurrentKeyModifiers();
HotKey hotKey = new((Keys)e.Key, currentModifiers);
var source = e.OriginalSource as DependencyObject;

// A textbox takes precedence over certain hotkeys.
if (e.OriginalSource is DependencyObject source && source.FindAscendantOrSelf<TextBox>() is not null)
if (source?.FindAscendantOrSelf<TextBox>() is not null)
break;

// Execute command for hotkey
var command = Commands[hotKey];

if (command.Code is CommandCodes.OpenItem && source?.FindAscendantOrSelf<PathBreadcrumb>() is not null)
break;


if (command.Code is not CommandCodes.None && keyReleased)
{
keyReleased = false;
Expand Down