mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:38:11 +00:00
LibGUI: Widget::action_for_key_event() should fail for invalid shortcuts (#4137)
Previously GUI::Actions which were constructed without initializing m_shortcut could be activated via an invalid GUI::Shortcut. Steps to reproduce: It was possible to enable TextEditor's markdown preview by pressing Ctrl or Alt (Cmd/Ctrl) keys, which should not happen, as this Action did not specify a shortcut. This fix should apply to all other cases where actions where declared without specifying a shortcut.
This commit is contained in:
parent
e7e179212c
commit
c6bb3d452a
1 changed files with 5 additions and 0 deletions
|
@ -739,6 +739,11 @@ bool Widget::is_backmost() const
|
|||
Action* Widget::action_for_key_event(const KeyEvent& event)
|
||||
{
|
||||
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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue