Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 027f776

Browse files
0x5bfayaira2
authored andcommitted
Init
1 parent 16da0e1 commit 027f776

File tree

5 files changed

+26
-13
lines changed

5 files changed

+26
-13
lines changed

‎src/Files.App.Controls/BreadcrumbBar/BreadcrumbBar.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License.
33

44
using Microsoft.UI.Xaml.Automation;
5+
using Microsoft.UI.Xaml.Input;
56
using Windows.Foundation;
67

78
namespace Files.App.Controls
@@ -67,10 +68,10 @@ protected override void OnApplyTemplate()
6768
_itemsRepeater.ItemsSourceView.CollectionChanged += ItemsSourceView_CollectionChanged;
6869
}
6970

70-
internal protected virtual void RaiseItemClickedEvent(BreadcrumbBarItem item)
71+
internal protected virtual void RaiseItemClickedEvent(BreadcrumbBarItem item,PointerRoutedEventArgs?pointerRoutedEventArgs=null)
7172
{
7273
var index = _itemsRepeater?.GetElementIndex(item) ?? throw new ArgumentNullException($"{_itemsRepeater} is null.");
73-
var eventArgs = new BreadcrumbBarItemClickedEventArgs(item, index, item == _rootBreadcrumbBarItem);
74+
var eventArgs = new BreadcrumbBarItemClickedEventArgs(item, index, item == _rootBreadcrumbBarItem,pointerRoutedEventArgs);
7475
ItemClicked?.Invoke(this, eventArgs);
7576
}
7677

‎src/Files.App.Controls/BreadcrumbBar/BreadcrumbBarItem.Events.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ namespace Files.App.Controls
88
{
99
public partial class BreadcrumbBarItem
1010
{
11-
private void ItemContentButton_Click(object sender, RoutedEventArgs e)
12-
{
13-
OnItemClicked();
14-
}
15-
1611
private void ItemChevronButton_Click(object sender, RoutedEventArgs e)
1712
{
1813
FlyoutBase.ShowAttachedFlyout(_itemChevronButton);

‎src/Files.App.Controls/BreadcrumbBar/BreadcrumbBarItem.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// Copyright (c) Files Community
22
// Licensed under the MIT License.
33

4+
using Microsoft.UI.Input;
5+
using Microsoft.UI.Xaml.Input;
6+
47
namespace Files.App.Controls
58
{
69
public partial class BreadcrumbBarItem : ContentControl
@@ -46,7 +49,16 @@ protected override void OnApplyTemplate()
4649
if (IsEllipsis || IsLastItem)
4750
VisualStateManager.GoToState(this, "ChevronCollapsed", true);
4851

49-
_itemContentButton.Click += ItemContentButton_Click;
52+
// Handle click event with PointerReleasedEvent to get PointerPoint
53+
_itemContentButton.AddHandler( // Bypass "IsHandled = true" done in the base class
54+
PointerReleasedEvent,
55+
new PointerEventHandler((s, e) =>
56+
{
57+
OnItemClicked(e);
58+
e.Handled = true;
59+
}),
60+
handledEventsToo: true);
61+
5062
_itemContentButton.PreviewKeyDown += ItemContentButton_PreviewKeyDown;
5163
_itemChevronButton.Click += ItemChevronButton_Click;
5264
_itemChevronButton.PreviewKeyDown += ItemChevronButton_PreviewKeyDown;
@@ -55,7 +67,7 @@ protected override void OnApplyTemplate()
5567
_itemChevronDropDownMenuFlyout.Closed += ChevronDropDownMenuFlyout_Closed;
5668
}
5769

58-
public void OnItemClicked()
70+
public void OnItemClicked(PointerRoutedEventArgs?pointerRoutedEventArgs=null)
5971
{
6072
if (_ownerRef is null ||
6173
!_ownerRef.TryGetTarget(out var breadcrumbBar))
@@ -73,7 +85,7 @@ public void OnItemClicked()
7385
{
7486
var menuFlyoutItem = new MenuFlyoutItem() { Text = text };
7587
_itemEllipsisDropDownMenuFlyout.Items.Add(menuFlyoutItem);
76-
menuFlyoutItem.Click += (sender, e) => breadcrumbBar.RaiseItemClickedEvent(item);
88+
menuFlyoutItem.Click += (sender, e) => breadcrumbBar.RaiseItemClickedEvent(item,pointerRoutedEventArgs);
7789
}
7890
}
7991

@@ -83,7 +95,7 @@ public void OnItemClicked()
8395
else
8496
{
8597
// Fire a click event
86-
breadcrumbBar.RaiseItemClickedEvent(this);
98+
breadcrumbBar.RaiseItemClickedEvent(this,pointerRoutedEventArgs);
8799
}
88100
}
89101

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// Copyright (c) Files Community
22
// Licensed under the MIT License.
33

4+
using Microsoft.UI.Xaml.Input;
5+
46
namespace Files.App.Controls
57
{
6-
public record class BreadcrumbBarItemClickedEventArgs(BreadcrumbBarItem Item, int Index, bool IsRootItem = false);
8+
public record class BreadcrumbBarItemClickedEventArgs(BreadcrumbBarItem Item, int Index, bool IsRootItem = false,PointerRoutedEventArgs?PointerRoutedEventArgs=null);
79

810
public record class BreadcrumbBarItemDropDownFlyoutEventArgs(MenuFlyout Flyout, BreadcrumbBarItem? Item = null, int Index = -1, bool IsRootItem = false);
911
}

‎src/Files.App/UserControls/NavigationToolbar.xaml.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,10 @@ private async void BreadcrumbBar_ItemClicked(Controls.BreadcrumbBar sender, Cont
279279
ViewModel.PathComponents[args.Index].Path is not { } path)
280280
return;
281281

282-
await ViewModel.HandleFolderNavigationAsync(path);
282+
// If user clicked the item with middle mouse button, open it in new tab
283+
var openInNewTab = args.PointerRoutedEventArgs?.GetCurrentPoint(null).Properties.PointerUpdateKind is PointerUpdateKind.MiddleButtonReleased;
284+
285+
await ViewModel.HandleFolderNavigationAsync(path, openInNewTab);
283286
}
284287

285288
private async void BreadcrumbBar_ItemDropDownFlyoutOpening(object sender, BreadcrumbBarItemDropDownFlyoutEventArgs e)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /