Skip to content

Commit bb9e94e

Browse files
authored
Merge pull request #257 from jeffsieu/enter-keybinding
Add enter keybinding to open file/folder
2 parents 2705d11 + 3bf92b7 commit bb9e94e

File tree

5 files changed

+92
-328
lines changed

5 files changed

+92
-328
lines changed

Files UWP/GenericFileBrowser.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@
199199
</Grid.ContextFlyout>
200200
<ProgressBar x:Name="progBar" Height="10" VerticalAlignment="Top" IsIndeterminate="True"/>
201201
<TextBlock Visibility="{x:Bind Mode=TwoWay, Path=TextState.isVisible, UpdateSourceTrigger=PropertyChanged}" x:Name="EmptyText" HorizontalAlignment="Center" Text="This folder is empty." TextWrapping="Wrap" VerticalAlignment="Top" Margin="0,125,0,0"/>
202-
<controls:DataGrid ItemsSource="{x:Bind viewModelInstance.FilesAndFolders}" ScrollViewer.IsScrollInertiaEnabled="True" ClipboardCopyMode="None" RowDetailsVisibilityMode="Collapsed" AllowDrop="True" Drop="AllView_DropAsync" DragLeave="AllView_DragLeave" DragStarting="AllView_DragStarting" SelectionChanged="AllView_SelectionChanged" Margin="24,24,0,0" Grid.Row="3" CellEditEnded="AllView_CellEditEnded" FocusVisualPrimaryThickness="0" SelectionMode="Extended" IsDoubleTapEnabled="True" x:FieldModifier="public" x:Name="AllView" AutoGenerateColumns="False" CanDrag="True" DragOver="AllView_DragOver" IsRightTapEnabled="True" CanUserReorderColumns="False" IsReadOnly="True" HorizontalAlignment="Left">
202+
<controls:DataGrid ItemsSource="{x:Bind viewModelInstance.FilesAndFolders}" PreviewKeyDown="AllView_PreviewKeyDown" ScrollViewer.IsScrollInertiaEnabled="True" ClipboardCopyMode="None" RowDetailsVisibilityMode="Collapsed" AllowDrop="True" Drop="AllView_DropAsync" DragLeave="AllView_DragLeave" DragStarting="AllView_DragStarting" SelectionChanged="AllView_SelectionChanged" Margin="24,24,0,0" Grid.Row="3" CellEditEnded="AllView_CellEditEnded" FocusVisualPrimaryThickness="0" SelectionMode="Extended" IsDoubleTapEnabled="True" x:FieldModifier="public" x:Name="AllView" AutoGenerateColumns="False" CanDrag="True" DragOver="AllView_DragOver" IsRightTapEnabled="True" CanUserReorderColumns="False" IsReadOnly="True" HorizontalAlignment="Left">
203203
<controls:DataGrid.Resources>
204204
<SolidColorBrush x:Key="DataGridCellFocusVisualPrimaryBrush" Color="Transparent"/>
205205
<SolidColorBrush x:Key="DataGridCellFocusVisualSecondaryBrush" Color="Transparent"/>

Files UWP/GenericFileBrowser.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
using Windows.UI.Core;
1414
using System.Text.RegularExpressions;
1515
using System.IO;
16+
using Windows.System;
17+
using Windows.UI.Xaml.Input;
1618

1719
namespace Files
1820
{
@@ -329,6 +331,14 @@ private void RightClickContextMenu_Opened(object sender, object e)
329331
}
330332
}
331333

334+
private void AllView_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
335+
{
336+
if (e.Key == VirtualKey.Enter)
337+
{
338+
tabInstance.instanceInteraction.List_ItemClick(null, null);
339+
e.Handled = true;
340+
}
341+
}
332342
}
333343

334344
public class EmptyFolderTextState : INotifyPropertyChanged

0 commit comments

Comments
 (0)