From 794911aad4c29836aa19ee1dd60533d26ef42acf Mon Sep 17 00:00:00 2001 From: Zelin Liao Date: Sat, 26 Jun 2021 10:52:44 +0800 Subject: [PATCH 1/2] [Plugin.Shell] Fix: The Query Box Is Not Focused When HotKey Invoked --- Plugins/Flow.Launcher.Plugin.Shell/Main.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Shell/Main.cs b/Plugins/Flow.Launcher.Plugin.Shell/Main.cs index 829398a4b8c..fe6726d575d 100644 --- a/Plugins/Flow.Launcher.Plugin.Shell/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Shell/Main.cs @@ -298,7 +298,12 @@ bool API_GlobalKeyboardEvent(int keyevent, int vkcode, SpecialKeyState state) private void OnWinRPressed() { context.API.ChangeQuery($"{context.CurrentPluginMetadata.ActionKeywords[0]}{Plugin.Query.TermSeperater}"); - Application.Current.MainWindow.Visibility = Visibility.Visible; + + // show the main window and set focus to the query box + Window mainWindow = Application.Current.MainWindow; + mainWindow.Visibility = Visibility.Visible; + mainWindow.Activate(); + mainWindow.Focus(); } public Control CreateSettingPanel() From 867c2a711b3486f09e621e41e7cab3a8245fa69f Mon Sep 17 00:00:00 2001 From: Zelin Liao Date: Sat, 26 Jun 2021 20:42:09 +0800 Subject: [PATCH 2/2] Remove Uncessary Window.Activate() --- Flow.Launcher/CustomQueryHotkeySetting.xaml.cs | 11 +++++++++-- Plugins/Flow.Launcher.Plugin.Shell/Main.cs | 1 - 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs b/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs index d036c008c58..813c5e25474 100644 --- a/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs +++ b/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs @@ -55,7 +55,7 @@ private void btnAdd_OnClick(object sender, RoutedEventArgs e) SetHotkey(ctlHotkey.CurrentHotkey, delegate { App.API.ChangeQuery(pluginHotkey.ActionKeyword); - Application.Current.MainWindow.Visibility = Visibility.Visible; + ShowMainWindow(); }); } else @@ -73,11 +73,18 @@ private void btnAdd_OnClick(object sender, RoutedEventArgs e) SetHotkey(new HotkeyModel(updateCustomHotkey.Hotkey), delegate { App.API.ChangeQuery(updateCustomHotkey.ActionKeyword); - Application.Current.MainWindow.Visibility = Visibility.Visible; + ShowMainWindow(); }); } Close(); + + static void ShowMainWindow() + { + Window mainWindow = Application.Current.MainWindow; + mainWindow.Visibility = Visibility.Visible; + mainWindow.Focus(); + } } public void UpdateItem(CustomPluginHotkey item) diff --git a/Plugins/Flow.Launcher.Plugin.Shell/Main.cs b/Plugins/Flow.Launcher.Plugin.Shell/Main.cs index fe6726d575d..58f8538f0f2 100644 --- a/Plugins/Flow.Launcher.Plugin.Shell/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Shell/Main.cs @@ -302,7 +302,6 @@ private void OnWinRPressed() // show the main window and set focus to the query box Window mainWindow = Application.Current.MainWindow; mainWindow.Visibility = Visibility.Visible; - mainWindow.Activate(); mainWindow.Focus(); }