1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:27:45 +00:00

LibGUI: Handle Action keyboard shortcuts in Widget keydown

Widgets can now prevent shortcut Actions from being called, which
allows text input keydown handlers to override single key shortcuts.
This commit is contained in:
Zaggy1024 2022-10-24 19:05:40 -05:00 committed by Sam Atkins
parent 8e7c7e0a2a
commit 967dfa7956
6 changed files with 72 additions and 13 deletions

View file

@ -188,16 +188,6 @@ void ConnectionToWindowServer::key_down(i32 window_id, u32 code_point, u32 key,
auto key_event = make<KeyEvent>(Event::KeyDown, (KeyCode)key, modifiers, code_point, scancode);
if (auto* action = action_for_shortcut(*window, Shortcut(key_event->modifiers(), key_event->key()))) {
if (action->is_enabled()) {
action->flash_menubar_menu(*window);
action->activate();
return;
}
if (action->swallow_key_event_when_disabled())
return;
}
bool focused_widget_accepts_emoji_input = window->focused_widget() && window->focused_widget()->on_emoji_input;
if (!window->blocks_emoji_input() && focused_widget_accepts_emoji_input && (modifiers == (Mod_Ctrl | Mod_Alt)) && key == Key_Space) {
auto emoji_input_dialog = EmojiInputDialog::construct(window);