Skip to content

Commit 9ce15df

Browse files
authored
Added support for opening folders in a new tab by clicking the middle mouse button (#2389)
1 parent 130dfb6 commit 9ce15df

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

Files/Interacts/Interaction.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,23 @@ await CoreWindow.GetForCurrentThread().Dispatcher.RunAsync(CoreDispatcherPriorit
145145
}
146146
}
147147

148+
public void ItemPointerPressed(object sender, PointerRoutedEventArgs e)
149+
{
150+
if (e.GetCurrentPoint(null).Properties.IsMiddleButtonPressed)
151+
{
152+
if ((e.OriginalSource as FrameworkElement)?.DataContext is ListedItem Item && Item.PrimaryItemAttribute == StorageItemTypes.Folder)
153+
{
154+
if (Item.IsShortcutItem)
155+
{
156+
OpenPathInNewTab(((e.OriginalSource as FrameworkElement)?.DataContext as ShortcutItem)?.TargetPath ?? Item.ItemPath);
157+
}
158+
else
159+
{
160+
OpenPathInNewTab(Item.ItemPath);
161+
}
162+
}
163+
}
164+
}
148165
public static async void OpenPathInNewTab(string path)
149166
{
150167
await MainPage.AddNewTabByPathAsync(typeof(ModernShellPage), path);

Files/Views/LayoutModes/GenericFileBrowser.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,7 @@
656656
IsRightTapEnabled="True"
657657
ItemsSource="{x:Bind ParentShellPageInstance.FilesystemViewModel.FilesAndFolders, Mode=OneWay}"
658658
LoadingRow="AllView_LoadingRow"
659+
PointerPressed="{x:Bind ParentShellPageInstance.InteractionOperations.ItemPointerPressed}"
659660
PreparingCellForEdit="AllView_PreparingCellForEdit"
660661
PreviewKeyDown="AllView_PreviewKeyDown"
661662
RightTapped="AllView_RightTapped"

Files/Views/LayoutModes/GridViewBrowser.xaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ private void GridViewBrowserViewer_PointerPressed(object sender, PointerRoutedEv
142142
{
143143
ClearSelection();
144144
}
145+
else if (e.GetCurrentPoint(null).Properties.IsMiddleButtonPressed)
146+
{
147+
ParentShellPageInstance.InteractionOperations.ItemPointerPressed(sender, e);
148+
}
145149
}
146150

147151
private void FileList_SelectionChanged(object sender, SelectionChangedEventArgs e)

0 commit comments

Comments
 (0)