From b842f08b5147de1cc504f723df3a870064801bbd Mon Sep 17 00:00:00 2001 From: DB p Date: Fri, 11 Apr 2025 13:23:17 +0900 Subject: [PATCH 1/3] Add logic to block space key input when registering an action keyword for plugins that do not support multiple action keywords. --- .../Views/ActionKeywordSetting.xaml | 1 + .../Views/ActionKeywordSetting.xaml.cs | 21 +++++++++++ .../SearchSourceSetting.xaml | 36 ++++++++++--------- .../SearchSourceSetting.xaml.cs | 26 ++++++++++++++ 4 files changed, 67 insertions(+), 17 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml index d42505348..37a7ccb8d 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml @@ -80,6 +80,7 @@ Width="135" HorizontalAlignment="Left" VerticalAlignment="Center" + DataObject.Pasting="TextBox_Pasting" PreviewKeyDown="TxtCurrentActionKeyword_OnKeyDown" Text="{Binding ActionKeyword}" /> diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs index 73c35b1c8..b928a9815 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.ComponentModel; +using System.Linq; using System.Runtime.CompilerServices; using System.Windows; using System.Windows.Input; @@ -93,7 +94,27 @@ namespace Flow.Launcher.Plugin.Explorer.Views OnDoneButtonClick(sender, e); e.Handled = true; } + if (e.Key == Key.Space) + { + e.Handled = true; + } } + private void TextBox_Pasting(object sender, DataObjectPastingEventArgs e) + { + if (e.DataObject.GetDataPresent(DataFormats.Text)) + { + string text = e.DataObject.GetData(DataFormats.Text) as string; + if (!string.IsNullOrEmpty(text) && text.Any(char.IsWhiteSpace)) + { + e.CancelCommand(); + } + } + else + { + e.CancelCommand(); + } + } + public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml b/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml index 3df50b3ed..746c9cf84 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml @@ -56,13 +56,13 @@ - + - +