mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:47:44 +00:00
LibGUI: Make propagate_shortcuts
handle different level of propagation
First, this patch renames the function `propagate_shortcuts_up_to_application` to `propagate_shortcuts`. Handling those levels, will allow us to differentiate shortcuts at `Window` level and `Application` level. Which will be convenient to handle dialog-specific shortcuts.
This commit is contained in:
parent
0b14ef134d
commit
baac824ee3
4 changed files with 12 additions and 7 deletions
|
@ -479,7 +479,7 @@ void Window::handle_multi_paint_event(MultiPaintEvent& event)
|
|||
ConnectionToWindowServer::the().async_did_finish_painting(m_window_id, rects);
|
||||
}
|
||||
|
||||
void Window::propagate_shortcuts_up_to_application(KeyEvent& event, Widget* widget)
|
||||
void Window::propagate_shortcuts(KeyEvent& event, Widget* widget, ShortcutPropagationBoundary boundary)
|
||||
{
|
||||
VERIFY(event.type() == Event::KeyDown);
|
||||
auto shortcut = Shortcut(event.modifiers(), event.key());
|
||||
|
@ -497,9 +497,9 @@ void Window::propagate_shortcuts_up_to_application(KeyEvent& event, Widget* widg
|
|||
} while (widget);
|
||||
}
|
||||
|
||||
if (!action)
|
||||
if (!action && boundary >= ShortcutPropagationBoundary::Window)
|
||||
action = action_for_shortcut(shortcut);
|
||||
if (!action)
|
||||
if (!action && boundary >= ShortcutPropagationBoundary::Application)
|
||||
action = Application::the()->action_for_shortcut(shortcut);
|
||||
|
||||
if (action) {
|
||||
|
@ -533,7 +533,7 @@ void Window::handle_key_event(KeyEvent& event)
|
|||
|
||||
// Only process shortcuts if this is a keydown event.
|
||||
if (event.type() == Event::KeyDown)
|
||||
propagate_shortcuts_up_to_application(event, nullptr);
|
||||
propagate_shortcuts(event, nullptr, PropagationLimit::Application);
|
||||
}
|
||||
|
||||
void Window::handle_resize_event(ResizeEvent& event)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue