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: 0 additions & 2 deletions src/Files.App/Data/Items/FileTagItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Licensed under the MIT License. See the LICENSE.

using CommunityToolkit.WinUI.Helpers;
using Files.App.Converters;
using Files.Core.ViewModels.FileTags;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Markup;
Expand Down
3 changes: 2 additions & 1 deletion src/Files.App/UserControls/SideBar/ISideBarViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Microsoft.UI.Input;
using Microsoft.UI.Xaml;
using Windows.ApplicationModel.DataTransfer;
using Windows.Foundation;
Expand Down Expand Up @@ -42,6 +43,6 @@ public interface ISidebarViewModel
/// Gets invoked when an item is invoked (double clicked) on any item of the sidebar.
/// </summary>
/// <param name="item">The item that was invoked.</param>
void HandleItemInvokedAsync(object item);
void HandleItemInvokedAsync(object item, PointerUpdateKind pointerUpdateKind);
}
}
17 changes: 9 additions & 8 deletions src/Files.App/UserControls/SideBar/SideBarItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public SidebarItem()
{
if (args.Key == Windows.System.VirtualKey.Enter)
{
Clicked();
Clicked(PointerUpdateKind.Other);
args.Handled = true;
}
};
Expand Down Expand Up @@ -237,7 +237,7 @@ private void ChildrenPresenter_ElementPrepared(ItemsRepeater sender, ItemsRepeat
}
}

internal void Clicked()
internal void Clicked(PointerUpdateKind pointerUpdateKind)
{
if (IsGroupHeader)
{
Expand All @@ -250,12 +250,12 @@ internal void Clicked()
SetFlyoutOpen(true);
}
}
RaiseItemInvoked();
RaiseItemInvoked(pointerUpdateKind);
}

internal void RaiseItemInvoked()
internal void RaiseItemInvoked(PointerUpdateKind pointerUpdateKind)
{
Owner?.RaiseItemInvoked(this);
Owner?.RaiseItemInvoked(this, pointerUpdateKind);
}

private void SidebarDisplayModeChanged(SidebarDisplayMode oldValue)
Expand Down Expand Up @@ -386,10 +386,11 @@ private void Item_PointerReleased(object sender, Microsoft.UI.Xaml.Input.Pointer
UpdatePointerState();

VisualStateManager.GoToState(this, IsExpanded ? "ExpandedIconNormal" : "CollapsedIconNormal", true);
var updateKind = e.GetCurrentPoint(null).Properties.PointerUpdateKind;
if (updateKind == PointerUpdateKind.LeftButtonReleased)
var pointerUpdateKind = e.GetCurrentPoint(null).Properties.PointerUpdateKind;
if (pointerUpdateKind == PointerUpdateKind.LeftButtonReleased ||
pointerUpdateKind == PointerUpdateKind.MiddleButtonReleased)
{
Clicked();
Clicked(pointerUpdateKind);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/UserControls/SideBar/SideBarView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ internal void UpdateSelectedItemContainer(SidebarItem container)
SelectedItemContainer = container;
}

internal void RaiseItemInvoked(SidebarItem item)
internal void RaiseItemInvoked(SidebarItem item, PointerUpdateKind pointerUpdateKind)
{
// Only leaves can be selected
if (item.Item is null || item.IsGroupHeader) return;

SelectedItem = item.Item;
ItemInvoked?.Invoke(item, item.Item);
ViewModel.HandleItemInvokedAsync(item.Item);
ViewModel.HandleItemInvokedAsync(item.Item, pointerUpdateKind);
}

internal void RaiseContextRequested(SidebarItem item, Point e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License. See the LICENSE.

using CommunityToolkit.WinUI.UI;
using Microsoft.UI.Input;
using Microsoft.UI.Xaml.Automation;
using Microsoft.UI.Xaml.Automation.Peers;
using Microsoft.UI.Xaml.Automation.Provider;
Expand Down Expand Up @@ -74,7 +75,7 @@ public void Expand()

public void Invoke()
{
Owner.RaiseItemInvoked();
Owner.RaiseItemInvoked(PointerUpdateKind.Other);
}

public void AddToSelection()
Expand Down
9 changes: 6 additions & 3 deletions src/Files.App/ViewModels/UserControls/SidebarViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ private async void ItemContextMenuFlyout_Opened(object? sender, object e)
await ShellContextmenuHelper.LoadShellMenuItemsAsync(rightClickedItem.Path, itemContextMenuFlyout, rightClickedItem.MenuOptions);
}

public async void HandleItemInvokedAsync(object item)
public async void HandleItemInvokedAsync(object item, PointerUpdateKind pointerUpdateKind)
{
if (item is not INavigationControlItem navigationControlItem) return;
var navigationPath = item as string;
Expand All @@ -722,9 +722,12 @@ public async void HandleItemInvokedAsync(object item)
return;

var ctrlPressed = InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Control).HasFlag(CoreVirtualKeyStates.Down);
if (ctrlPressed && navigationPath is not null)
var middleClickPressed = pointerUpdateKind == PointerUpdateKind.MiddleButtonReleased;
if ((ctrlPressed ||
middleClickPressed) &&
navigationControlItem.Path is not null)
{
await NavigationHelpers.OpenPathInNewTab(navigationPath);
await NavigationHelpers.OpenPathInNewTab(navigationControlItem.Path);
return;
}

Expand Down