From 5715dcd946442d36fe8b8d5a95190512e124da6b Mon Sep 17 00:00:00 2001 From: Sparrkle Date: Wed, 14 Sep 2022 17:50:42 +0900 Subject: [PATCH 1/4] Fixed Query Textbox Binding event --- Flow.Launcher/MainWindow.xaml | 3 ++- Flow.Launcher/MainWindow.xaml.cs | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index 714fcc53fa1..a3ea9c831f8 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -173,7 +173,8 @@ Background="Transparent" PreviewDragOver="OnPreviewDragOver" Style="{DynamicResource QueryBoxStyle}" - Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" + Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=Explicit}" + PreviewKeyUp="QueryTextBox_KeyUp" Visibility="Visible"> diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 2b7db38cff2..a4d02fb50b6 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.ComponentModel; using System.Threading.Tasks; using System.Windows; @@ -20,6 +20,7 @@ using System.Windows.Media; using Flow.Launcher.Infrastructure.Hotkey; using Flow.Launcher.Plugin.SharedCommands; +using System.Windows.Data; namespace Flow.Launcher { @@ -555,5 +556,11 @@ public void InitializeColorScheme() ModernWpf.ThemeManager.Current.ApplicationTheme = ModernWpf.ApplicationTheme.Dark; } } + + private void QueryTextBox_KeyUp(object sender, KeyEventArgs e) + { + BindingExpression be = QueryTextBox.GetBindingExpression(System.Windows.Controls.TextBox.TextProperty); + be.UpdateSource(); + } } -} \ No newline at end of file +} From d4ffa93395aa2691becedfa4b2608376fc81d9b0 Mon Sep 17 00:00:00 2001 From: Sparrkle Date: Thu, 15 Sep 2022 15:25:20 +0900 Subject: [PATCH 2/4] Modified to trigger when the value changes. --- Flow.Launcher/MainWindow.xaml.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index a4d02fb50b6..20bfa0d620f 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -21,6 +21,7 @@ using Flow.Launcher.Infrastructure.Hotkey; using Flow.Launcher.Plugin.SharedCommands; using System.Windows.Data; +using System.Diagnostics; namespace Flow.Launcher { @@ -559,8 +560,7 @@ public void InitializeColorScheme() private void QueryTextBox_KeyUp(object sender, KeyEventArgs e) { - BindingExpression be = QueryTextBox.GetBindingExpression(System.Windows.Controls.TextBox.TextProperty); - be.UpdateSource(); + _viewModel.ChangeQueryText(QueryTextBox.Text); } } } From ee44b4c2d4c9b4fad7aa2473d1223961b704e413 Mon Sep 17 00:00:00 2001 From: Sparrkle Date: Fri, 16 Sep 2022 11:21:09 +0900 Subject: [PATCH 3/4] Modified different way. fixed a bug not triggered while the backspace was pressed. --- Flow.Launcher/MainWindow.xaml | 2 +- Flow.Launcher/MainWindow.xaml.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index a3ea9c831f8..bd02b560a87 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -173,7 +173,7 @@ Background="Transparent" PreviewDragOver="OnPreviewDragOver" Style="{DynamicResource QueryBoxStyle}" - Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=Explicit}" + Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" PreviewKeyUp="QueryTextBox_KeyUp" Visibility="Visible"> diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 20bfa0d620f..2580194574d 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -560,7 +560,8 @@ public void InitializeColorScheme() private void QueryTextBox_KeyUp(object sender, KeyEventArgs e) { - _viewModel.ChangeQueryText(QueryTextBox.Text); + if(_viewModel.QueryText != QueryTextBox.Text) + _viewModel.QueryText = QueryTextBox.Text; } } } From 54df39c01cb6d4d767f899ecceb39390419b11f6 Mon Sep 17 00:00:00 2001 From: Sparrkle Date: Wed, 21 Sep 2022 20:13:50 +0900 Subject: [PATCH 4/4] Fixed QueryTextBox Binding Error. --- Flow.Launcher/MainWindow.xaml.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 2580194574d..bc952681d95 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -561,7 +561,10 @@ public void InitializeColorScheme() private void QueryTextBox_KeyUp(object sender, KeyEventArgs e) { if(_viewModel.QueryText != QueryTextBox.Text) - _viewModel.QueryText = QueryTextBox.Text; + { + BindingExpression be = QueryTextBox.GetBindingExpression(System.Windows.Controls.TextBox.TextProperty); + be.UpdateSource(); + } } } }