Merge pull request #489 from lzl1918/lzl1918/FixShellPluginDoesNotAutoFocus

[Plugin.Shell] Fix: The Query Box Is Not Focused When HotKey Invoked
This commit is contained in:
Kevin Zhang 2021-06-27 12:56:13 +08:00 committed by GitHub
commit a312fe8581
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View file

@ -55,7 +55,7 @@ namespace Flow.Launcher
SetHotkey(ctlHotkey.CurrentHotkey, delegate
{
App.API.ChangeQuery(pluginHotkey.ActionKeyword);
Application.Current.MainWindow.Visibility = Visibility.Visible;
ShowMainWindow();
});
}
else
@ -73,11 +73,18 @@ namespace Flow.Launcher
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)

View file

@ -298,7 +298,11 @@ namespace Flow.Launcher.Plugin.Shell
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.Focus();
}
public Control CreateSettingPanel()