From 9b0371c82b6a08b7fa65afc2adc4ecb3d5271f50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BC=98=E9=9F=AC?= Date: Sun, 18 Jul 2021 16:05:28 +0800 Subject: [PATCH] fix Custom Plugin Hotkey not deselect text when query text is already custom plugin hotkey --- Flow.Launcher/MainWindow.xaml | 1 - Flow.Launcher/MainWindow.xaml.cs | 15 +++++++++------ Flow.Launcher/ViewModel/MainViewModel.cs | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index 7d0632d7039..8b81bb94abe 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -79,7 +79,6 @@ Style="{DynamicResource QueryBoxStyle}" Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" PreviewDragOver="OnPreviewDragOver" - TextChanged="OnTextChanged" AllowDrop="True" Visibility="Visible" Background="Transparent" diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 5fab812e6e2..d97e020dc16 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -125,6 +125,13 @@ private void OnLoaded(object sender, RoutedEventArgs _) break; } + case nameof(MainViewModel.QueryTextCursorMovedToEnd): + if (_viewModel.QueryTextCursorMovedToEnd) + { + MoveQueryTextToEnd(); + _viewModel.QueryTextCursorMovedToEnd = false; + } + break; } }; _settings.PropertyChanged += (o, e) => @@ -329,13 +336,9 @@ private void OnKeyDown(object sender, KeyEventArgs e) } } - private void OnTextChanged(object sender, TextChangedEventArgs e) + private void MoveQueryTextToEnd() { - if (_viewModel.QueryTextCursorMovedToEnd) - { - QueryTextBox.CaretIndex = QueryTextBox.Text.Length; - _viewModel.QueryTextCursorMovedToEnd = false; - } + QueryTextBox.CaretIndex = QueryTextBox.Text.Length; } } } \ No newline at end of file diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 5b9706a32a5..ca6ffe84573 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -289,8 +289,8 @@ public string QueryText /// public void ChangeQueryText(string queryText) { - QueryTextCursorMovedToEnd = true; QueryText = queryText; + QueryTextCursorMovedToEnd = true; } public bool LastQuerySelected { get; set; }