mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:17: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:
parent
8e7c7e0a2a
commit
967dfa7956
6 changed files with 72 additions and 13 deletions
|
@ -344,10 +344,22 @@ void Widget::event(Core::Event& event)
|
|||
void Widget::handle_keydown_event(KeyEvent& event)
|
||||
{
|
||||
keydown_event(event);
|
||||
if (event.is_accepted())
|
||||
return;
|
||||
|
||||
if (auto action = Action::find_action_for_shortcut(*this, Shortcut(event.modifiers(), event.key()))) {
|
||||
action->process_event(*window(), event);
|
||||
if (event.is_accepted())
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.key() == KeyCode::Key_Menu) {
|
||||
ContextMenuEvent c_event(window_relative_rect().bottom_right(), screen_relative_rect().bottom_right());
|
||||
dispatch_event(c_event);
|
||||
return;
|
||||
}
|
||||
|
||||
event.ignore();
|
||||
}
|
||||
|
||||
void Widget::handle_paint_event(PaintEvent& event)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue