mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 04:39:06 +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
Notes:
sideshowbarker
2024-07-17 14:36:19 +09:00
Author: https://github.com/geordiemhall
Commit: 737c1c86dc
Pull-request: https://github.com/SerenityOS/serenity/pull/12291
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/bgianfo
8 changed files with 16 additions and 21 deletions
|
@ -904,14 +904,8 @@ bool Widget::is_backmost() const
|
|||
return &parent->children().first() == this;
|
||||
}
|
||||
|
||||
Action* Widget::action_for_key_event(KeyEvent const& event)
|
||||
Action* Widget::action_for_shortcut(Shortcut const& shortcut)
|
||||
{
|
||||
Shortcut shortcut(event.modifiers(), (KeyCode)event.key());
|
||||
|
||||
if (!shortcut.is_valid()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Action* found_action = nullptr;
|
||||
for_each_child_of_type<Action>([&](auto& action) {
|
||||
if (action.shortcut() == shortcut || action.alternate_shortcut() == shortcut) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue