From 9bbd01a1d73103e738ad99db7fc0f0c1ea2d1345 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Mon, 7 Nov 2022 21:10:05 +1100 Subject: [PATCH] add drag and drop for folders --- Flow.Launcher/ResultListBox.xaml.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Flow.Launcher/ResultListBox.xaml.cs b/Flow.Launcher/ResultListBox.xaml.cs index 734165f74..8a8ef3ab3 100644 --- a/Flow.Launcher/ResultListBox.xaml.cs +++ b/Flow.Launcher/ResultListBox.xaml.cs @@ -60,7 +60,7 @@ namespace Flow.Launcher private Point start; - private string file; + private string path; private string query; private void ResultList_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) @@ -68,7 +68,7 @@ namespace Flow.Launcher if (Mouse.DirectlyOver is not FrameworkElement { DataContext: ResultViewModel result }) return; - file = result.Result.CopyText; + path = result.Result.CopyText; query = result.Result.OriginQuery.RawQuery; start = e.GetPosition(null); } @@ -78,24 +78,28 @@ namespace Flow.Launcher if (e.LeftButton != MouseButtonState.Pressed) { start = default; - file = null; + path = null; return; } + if (!File.Exists(path) && !Directory.Exists(path)) + return; + Point mousePosition = e.GetPosition(null); Vector diff = this.start - mousePosition; if (Math.Abs(diff.X) < SystemParameters.MinimumHorizontalDragDistance - || Math.Abs(diff.Y) < SystemParameters.MinimumVerticalDragDistance - || !File.Exists(file)) + || Math.Abs(diff.Y) < SystemParameters.MinimumVerticalDragDistance) return; var data = new DataObject(DataFormats.FileDrop, new[] { - file + path }); DragDrop.DoDragDrop((DependencyObject)sender, data, DragDropEffects.Move | DragDropEffects.Copy); + App.API.ChangeQuery(query, true); + e.Handled = true; } }