diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs index d4eb02a90..cb60251ed 100644 --- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs +++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs @@ -88,6 +88,11 @@ namespace Flow.Launcher.Plugin /// Show the MainWindow when hiding /// void ShowMainWindow(); + + /// + /// Focus the query text box in the main window + /// + void FocusQueryTextBox(); /// /// Hide MainWindow diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index a0614d90f..7b80ec480 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -33,6 +33,7 @@ using JetBrains.Annotations; using Squirrel; using Stopwatch = Flow.Launcher.Infrastructure.Stopwatch; using System.ComponentModel; +using System.Windows.Input; namespace Flow.Launcher { @@ -92,6 +93,18 @@ namespace Flow.Launcher } public void ShowMainWindow() => _mainVM.Show(); + + public void FocusQueryTextBox() + { + Application.Current.Dispatcher.Invoke(new Action(() => + { + if (Application.Current.MainWindow is MainWindow mw) + { + mw.QueryTextBox.Focus(); + Keyboard.Focus(mw.QueryTextBox); + } + })); + } public void HideMainWindow() => _mainVM.Hide(); diff --git a/Plugins/Flow.Launcher.Plugin.Shell/Main.cs b/Plugins/Flow.Launcher.Plugin.Shell/Main.cs index 0d395c053..758ad09d5 100644 --- a/Plugins/Flow.Launcher.Plugin.Shell/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Shell/Main.cs @@ -378,10 +378,13 @@ namespace Flow.Launcher.Plugin.Shell private void OnWinRPressed() { + Context.API.ShowMainWindow(); // show the main window and set focus to the query box - _ = Task.Run(() => + _ = Task.Run(async () => { - Context.API.ShowMainWindow(); + await Task.Delay(50); // 💡 키보드 이벤트 처리가 끝난 뒤 + Context.API.FocusQueryTextBox(); + Context.API.ChangeQuery($"{Context.CurrentPluginMetadata.ActionKeywords[0]}{Plugin.Query.TermSeparator}"); }); }