File tree Expand file tree Collapse file tree 5 files changed +17
-14
lines changed Expand file tree Collapse file tree 5 files changed +17
-14
lines changed Original file line number Diff line number Diff line change 22// Licensed under the MIT License. See the LICENSE.
33
44using CommunityToolkit . WinUI . Helpers ;
5- using Files . App . Converters ;
6- using Files . Core . ViewModels . FileTags ;
75using Microsoft . UI . Xaml ;
86using Microsoft . UI . Xaml . Controls ;
97using Microsoft . UI . Xaml . Markup ;
Original file line number Diff line number Diff line change 11// Copyright (c) 2023 Files Community
22// Licensed under the MIT License. See the LICENSE.
33
4+ using Microsoft . UI . Input ;
45using Microsoft . UI . Xaml ;
56using Windows . ApplicationModel . DataTransfer ;
67using Windows . Foundation ;
@@ -42,6 +43,6 @@ public interface ISidebarViewModel
4243 /// Gets invoked when an item is invoked (double clicked) on any item of the sidebar.
4344 /// </summary>
4445 /// <param name="item">The item that was invoked.</param>
45- void HandleItemInvokedAsync ( object item ) ;
46+ void HandleItemInvokedAsync ( object item , PointerUpdateKind pointerUpdateKind ) ;
4647 }
4748}
Original file line number Diff line number Diff line change @@ -237,7 +237,7 @@ private void ChildrenPresenter_ElementPrepared(ItemsRepeater sender, ItemsRepeat
237237 }
238238 }
239239
240- internal void Clicked ( )
240+ internal void Clicked ( PointerUpdateKind pointerUpdateKind )
241241 {
242242 if ( IsGroupHeader )
243243 {
@@ -250,12 +250,12 @@ internal void Clicked()
250250 SetFlyoutOpen ( true ) ;
251251 }
252252 }
253- RaiseItemInvoked ( ) ;
253+ RaiseItemInvoked ( pointerUpdateKind ) ;
254254 }
255255
256- internal void RaiseItemInvoked ( )
256+ internal void RaiseItemInvoked ( PointerUpdateKind pointerUpdateKind )
257257 {
258- Owner ? . RaiseItemInvoked ( this ) ;
258+ Owner ? . RaiseItemInvoked ( this , pointerUpdateKind ) ;
259259 }
260260
261261 private void SidebarDisplayModeChanged ( SidebarDisplayMode oldValue )
@@ -386,10 +386,11 @@ private void Item_PointerReleased(object sender, Microsoft.UI.Xaml.Input.Pointer
386386 UpdatePointerState ( ) ;
387387
388388 VisualStateManager . GoToState ( this , IsExpanded ? "ExpandedIconNormal" : "CollapsedIconNormal" , true ) ;
389- var updateKind = e . GetCurrentPoint ( null ) . Properties . PointerUpdateKind ;
390- if ( updateKind == PointerUpdateKind . LeftButtonReleased )
389+ var pointerUpdateKind = e . GetCurrentPoint ( null ) . Properties . PointerUpdateKind ;
390+ if ( pointerUpdateKind == PointerUpdateKind . LeftButtonReleased ||
391+ pointerUpdateKind == PointerUpdateKind . MiddleButtonReleased )
391392 {
392- Clicked ( ) ;
393+ Clicked ( pointerUpdateKind ) ;
393394 }
394395 }
395396
Original file line number Diff line number Diff line change @@ -39,14 +39,14 @@ internal void UpdateSelectedItemContainer(SidebarItem container)
3939 SelectedItemContainer = container ;
4040 }
4141
42- internal void RaiseItemInvoked ( SidebarItem item )
42+ internal void RaiseItemInvoked ( SidebarItem item , PointerUpdateKind pointerUpdateKind )
4343 {
4444 // Only leaves can be selected
4545 if ( item . Item is null || item . IsGroupHeader ) return ;
4646
4747 SelectedItem = item . Item ;
4848 ItemInvoked ? . Invoke ( item , item . Item ) ;
49- ViewModel . HandleItemInvokedAsync ( item . Item ) ;
49+ ViewModel . HandleItemInvokedAsync ( item . Item , pointerUpdateKind ) ;
5050 }
5151
5252 internal void RaiseContextRequested ( SidebarItem item , Point e )
Original file line number Diff line number Diff line change @@ -713,7 +713,7 @@ private async void ItemContextMenuFlyout_Opened(object? sender, object e)
713713 await ShellContextmenuHelper . LoadShellMenuItemsAsync ( rightClickedItem . Path , itemContextMenuFlyout , rightClickedItem . MenuOptions ) ;
714714 }
715715
716- public async void HandleItemInvokedAsync ( object item )
716+ public async void HandleItemInvokedAsync ( object item , PointerUpdateKind pointerUpdateKind )
717717 {
718718 if ( item is not INavigationControlItem navigationControlItem ) return ;
719719 var navigationPath = item as string ;
@@ -722,7 +722,10 @@ public async void HandleItemInvokedAsync(object item)
722722 return ;
723723
724724 var ctrlPressed = InputKeyboardSource . GetKeyStateForCurrentThread ( VirtualKey . Control ) . HasFlag ( CoreVirtualKeyStates . Down ) ;
725- if ( ctrlPressed && navigationPath is not null )
725+ var middleClickPressed = pointerUpdateKind == PointerUpdateKind . MiddleButtonReleased ;
726+ if ( ( ctrlPressed ||
727+ middleClickPressed ) &&
728+ navigationPath is not null )
726729 {
727730 await NavigationHelpers . OpenPathInNewTab ( navigationPath ) ;
728731 return ;
You can’t perform that action at this time.
0 commit comments