mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 02:13:56 +09:00
LibGUI: Actually use the Action alternate shortcut
This adds the actual functionality to Window and Application.
This commit is contained in:
parent
21a193ed5a
commit
3e6a5af32b
Notes:
sideshowbarker
2024-07-18 11:33:51 +09:00
Author: https://github.com/aatosmajava
Commit: 3e6a5af32b
Pull-request: https://github.com/SerenityOS/serenity/pull/8230
Reviewed-by: https://github.com/MaxWipfli
3 changed files with 4 additions and 2 deletions
|
@ -113,11 +113,13 @@ void Application::quit(int exit_code)
|
||||||
void Application::register_global_shortcut_action(Badge<Action>, Action& action)
|
void Application::register_global_shortcut_action(Badge<Action>, Action& action)
|
||||||
{
|
{
|
||||||
m_global_shortcut_actions.set(action.shortcut(), &action);
|
m_global_shortcut_actions.set(action.shortcut(), &action);
|
||||||
|
m_global_shortcut_actions.set(action.alternate_shortcut(), &action);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::unregister_global_shortcut_action(Badge<Action>, Action& action)
|
void Application::unregister_global_shortcut_action(Badge<Action>, Action& action)
|
||||||
{
|
{
|
||||||
m_global_shortcut_actions.remove(action.shortcut());
|
m_global_shortcut_actions.remove(action.shortcut());
|
||||||
|
m_global_shortcut_actions.remove(action.alternate_shortcut());
|
||||||
}
|
}
|
||||||
|
|
||||||
Action* Application::action_for_key_event(const KeyEvent& event)
|
Action* Application::action_for_key_event(const KeyEvent& event)
|
||||||
|
|
|
@ -829,7 +829,7 @@ Action* Widget::action_for_key_event(const KeyEvent& event)
|
||||||
|
|
||||||
Action* found_action = nullptr;
|
Action* found_action = nullptr;
|
||||||
for_each_child_of_type<Action>([&](auto& action) {
|
for_each_child_of_type<Action>([&](auto& action) {
|
||||||
if (action.shortcut() == shortcut) {
|
if (action.shortcut() == shortcut || action.alternate_shortcut() == shortcut) {
|
||||||
found_action = &action;
|
found_action = &action;
|
||||||
return IterationDecision::Break;
|
return IterationDecision::Break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -982,7 +982,7 @@ Action* Window::action_for_key_event(const KeyEvent& event)
|
||||||
Shortcut shortcut(event.modifiers(), (KeyCode)event.key());
|
Shortcut shortcut(event.modifiers(), (KeyCode)event.key());
|
||||||
Action* found_action = nullptr;
|
Action* found_action = nullptr;
|
||||||
for_each_child_of_type<Action>([&](auto& action) {
|
for_each_child_of_type<Action>([&](auto& action) {
|
||||||
if (action.shortcut() == shortcut) {
|
if (action.shortcut() == shortcut || action.alternate_shortcut() == shortcut) {
|
||||||
found_action = &action;
|
found_action = &action;
|
||||||
return IterationDecision::Break;
|
return IterationDecision::Break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue