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

LibGUI: Search for actions with a Shortcut instead of for KeyEvent

Instead of having widget/window/application create a shortcut from a
KeyEvent within their find methods, we'll just pass them a Shortcut
so that the "where to search" logic doesn't need to be duplicated
for different Shortcut types.

It also lets us handle invalid Shortcut rejection at a higher level,
with most things letting the caller be responsible for not searching
for actions with an invalid shortcut.
This commit is contained in:
Geordie Hall 2022-02-05 18:39:34 +11:00 committed by Linus Groh
parent a252c3e058
commit 737c1c86dc
8 changed files with 16 additions and 21 deletions

View file

@ -1090,9 +1090,8 @@ void Window::notify_state_changed(Badge<ConnectionToWindowServer>, bool minimize
}
}
Action* Window::action_for_key_event(KeyEvent const& event)
Action* Window::action_for_shortcut(Shortcut const& shortcut)
{
Shortcut shortcut(event.modifiers(), (KeyCode)event.key());
Action* found_action = nullptr;
for_each_child_of_type<Action>([&](auto& action) {
if (action.shortcut() == shortcut || action.alternate_shortcut() == shortcut) {