Skip to content

Commit 9bbd01a

Browse files
committed
add drag and drop for folders
1 parent b47206e commit 9bbd01a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

Flow.Launcher/ResultListBox.xaml.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ private void ListBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
6060

6161

6262
private Point start;
63-
private string file;
63+
private string path;
6464
private string query;
6565

6666
private void ResultList_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
6767
{
6868
if (Mouse.DirectlyOver is not FrameworkElement { DataContext: ResultViewModel result })
6969
return;
7070

71-
file = result.Result.CopyText;
71+
path = result.Result.CopyText;
7272
query = result.Result.OriginQuery.RawQuery;
7373
start = e.GetPosition(null);
7474
}
@@ -78,24 +78,28 @@ private void ResultList_MouseMove(object sender, MouseEventArgs e)
7878
if (e.LeftButton != MouseButtonState.Pressed)
7979
{
8080
start = default;
81-
file = null;
81+
path = null;
8282
return;
8383
}
8484

85+
if (!File.Exists(path) && !Directory.Exists(path))
86+
return;
87+
8588
Point mousePosition = e.GetPosition(null);
8689
Vector diff = this.start - mousePosition;
8790

8891
if (Math.Abs(diff.X) < SystemParameters.MinimumHorizontalDragDistance
89-
|| Math.Abs(diff.Y) < SystemParameters.MinimumVerticalDragDistance
90-
|| !File.Exists(file))
92+
|| Math.Abs(diff.Y) < SystemParameters.MinimumVerticalDragDistance)
9193
return;
9294

9395
var data = new DataObject(DataFormats.FileDrop, new[]
9496
{
95-
file
97+
path
9698
});
9799
DragDrop.DoDragDrop((DependencyObject)sender, data, DragDropEffects.Move | DragDropEffects.Copy);
100+
98101
App.API.ChangeQuery(query, true);
102+
99103
e.Handled = true;
100104
}
101105
}

0 commit comments

Comments
 (0)