diff --git a/Flow.Launcher.Plugin/Result.cs b/Flow.Launcher.Plugin/Result.cs index 7633e34a7..a1d3b83ab 100644 --- a/Flow.Launcher.Plugin/Result.cs +++ b/Flow.Launcher.Plugin/Result.cs @@ -37,7 +37,11 @@ namespace Flow.Launcher.Plugin /// user's clipboard when Ctrl + C is pressed on a result. If the text is a file/directory path /// flow will copy the actual file/folder instead of just the path text. /// - public string CopyText { get; set; } = string.Empty; + public string CopyText + { + get => string.IsNullOrEmpty(_copyText) ? SubTitle : _copyText; + set => _copyText = value; + } /// /// This holds the text which can be provided by plugin to help Flow autocomplete text @@ -81,6 +85,7 @@ namespace Flow.Launcher.Plugin /// Delegate to Get Image Source /// public IconDelegate Icon; + private string _copyText = string.Empty; /// /// Information for Glyph Icon (Prioritized than IcoPath/Icon if user enable Glyph Icons) diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index 006d394fe..3e89ae5e0 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -288,8 +288,6 @@ diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index ac0393855..72fd97b3b 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -374,41 +374,6 @@ namespace Flow.Launcher e.Handled = true; } - private Point start; - - private void ResultList_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) - { - this.start = e.GetPosition(null); - } - - private void ResultList_MouseMove(object sender, System.Windows.Input.MouseEventArgs e) - { - if (this.ResultListBox.SelectedItems.Count == 0) - { - return; - } - - Point mpos = e.GetPosition(null); - Vector diff = this.start - mpos; - - var r = (ResultListBox)sender; - var d = (DependencyObject)e.OriginalSource; - var item = ItemsControl.ContainerFromElement(r, d) as ListBoxItem; - var result = (ResultViewModel)item?.DataContext; - - if (e.LeftButton == MouseButtonState.Pressed && - Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance && - Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance) - { - string copyText = string.IsNullOrEmpty(result.Result.CopyText) ? result.Result.SubTitle : result.Result.CopyText; - string[] files = { copyText }; - var data = new DataObject(System.Windows.DataFormats.FileDrop, files); - DragDrop.DoDragDrop(this.ResultListBox, data, System.Windows.DragDropEffects.Move | System.Windows.DragDropEffects.Copy); - e.Handled = true; - } - } - - private async void OnContextMenusForSettingsClick(object sender, RoutedEventArgs e) { _viewModel.Hide(); diff --git a/Flow.Launcher/ResultListBox.xaml b/Flow.Launcher/ResultListBox.xaml index 869045526..1ece390d1 100644 --- a/Flow.Launcher/ResultListBox.xaml +++ b/Flow.Launcher/ResultListBox.xaml @@ -25,12 +25,15 @@ VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard" Visibility="{Binding Visbility}" - mc:Ignorable="d"> + mc:Ignorable="d" + PreviewMouseMove="ResultList_MouseMove" + PreviewMouseLeftButtonDown="ResultList_PreviewMouseLeftButtonDown"> -