mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:07:46 +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:
parent
a252c3e058
commit
737c1c86dc
8 changed files with 16 additions and 21 deletions
|
@ -136,9 +136,9 @@ void Application::unregister_global_shortcut_action(Badge<Action>, Action& actio
|
|||
m_global_shortcut_actions.remove(action.alternate_shortcut());
|
||||
}
|
||||
|
||||
Action* Application::action_for_key_event(KeyEvent const& event)
|
||||
Action* Application::action_for_shortcut(Shortcut const& shortcut) const
|
||||
{
|
||||
auto it = m_global_shortcut_actions.find(Shortcut(event.modifiers(), (KeyCode)event.key()));
|
||||
auto it = m_global_shortcut_actions.find(shortcut);
|
||||
if (it == m_global_shortcut_actions.end())
|
||||
return nullptr;
|
||||
return (*it).value;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue