Skip to content

Commit bbc804e

Browse files
committed
Update TabBar.xaml.cs
1 parent 20e04d0 commit bbc804e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/Files.App/UserControls/TabBar/TabBar.xaml.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ public Rectangle DragArea
6262
/// <summary> Starting time when dragging a tab. </summary>
6363
private DateTimeOffset dragStartTime;
6464

65+
/// <summary> Cancel the tag drag event. </summary>
66+
private bool cancelTagDrag;
67+
6568
public TabBar()
6669
{
6770
InitializeComponent();
@@ -139,10 +142,20 @@ private void TabHoverSelected(object sender, object e)
139142

140143
private void TabView_TabDragStarting(TabView sender, TabViewTabDragStartingEventArgs args)
141144
{
145+
cancelTagDrag = false;
142146
var tabViewItemArgs = (args.Item as TabBarItem).NavigationParameter;
143147
args.Data.Properties.Add(TabPathIdentifier, tabViewItemArgs.Serialize());
144148
args.Data.RequestedOperation = DataPackageOperation.Move;
145149

150+
PreviewKeyDown += (s, e) =>
151+
{
152+
if (e.Key is Windows.System.VirtualKey.Escape)
153+
{
154+
args.Cancel = true;
155+
cancelTagDrag = true;
156+
}
157+
};
158+
146159
InteropHelpers.GetCursorPos(out dragStartPoint);
147160
dragStartTime = DateTimeOffset.UtcNow;
148161
}
@@ -202,6 +215,9 @@ private async void TabView_TabStripDrop(object sender, DragEventArgs e)
202215

203216
private void TabView_TabDragCompleted(TabView sender, TabViewTabDragCompletedEventArgs args)
204217
{
218+
if (cancelTagDrag)
219+
return;
220+
205221
if (ApplicationData.Current.LocalSettings.Values.ContainsKey(TabDropHandledIdentifier) &&
206222
(bool)ApplicationData.Current.LocalSettings.Values[TabDropHandledIdentifier])
207223
{
@@ -220,6 +236,9 @@ private void TabView_TabDragCompleted(TabView sender, TabViewTabDragCompletedEve
220236

221237
private async void TabView_TabDroppedOutside(TabView sender, TabViewTabDroppedOutsideEventArgs args)
222238
{
239+
if (cancelTagDrag)
240+
return;
241+
223242
InteropHelpers.GetCursorPos(out var droppedPoint);
224243
var droppedTime = DateTimeOffset.UtcNow;
225244
var dragTime = droppedTime - dragStartTime;

0 commit comments

Comments
 (0)