1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:28:11 +00:00

LibGUI: CommandPalette: Fix key event capture for actions

This patch fixes an issue for applications that contain actions without
a modifier (e.g. PixelPaint). Previously when pressing any key bound to
an action while the CommandPalette was visible the action was forwarded
to the parent instead of the CommandPalette.
This commit is contained in:
faxe1008 2022-09-05 21:17:45 +02:00 committed by Andreas Kling
parent 5ff63a9eb0
commit d91469ebb1
3 changed files with 5 additions and 4 deletions

View file

@ -164,7 +164,7 @@ static Action* action_for_shortcut(Window& window, Shortcut const& shortcut)
}
// NOTE: Application-global shortcuts are ignored while a blocking modal window is up.
if (!window.is_blocking()) {
if (!window.is_blocking() && !window.is_capturing_input()) {
if (auto* action = Application::the()->action_for_shortcut(shortcut)) {
dbgln_if(KEYBOARD_SHORTCUTS_DEBUG, " > Asked application, got action: {} {} (enabled: {}, shortcut: {}, alt-shortcut: {})", action, action->text(), action->is_enabled(), action->shortcut().to_string(), action->alternate_shortcut().to_string());
return action;
@ -214,7 +214,7 @@ void ConnectionToWindowServer::key_down(i32 window_id, u32 code_point, u32 key,
// FIXME: This shortcut should be configurable.
if (accepts_command_palette && !m_in_command_palette && modifiers == (Mod_Ctrl | Mod_Shift) && key == Key_A) {
auto command_palette = CommandPalette::construct(*window);
command_palette->set_window_mode(GUI::WindowMode::Passive);
command_palette->set_window_mode(GUI::WindowMode::CaptureInput);
TemporaryChange change { m_in_command_palette, true };
if (command_palette->exec() != GUI::Dialog::ExecResult::OK)
return;