mirror of
https://github.com/RGBCube/serenity
synced 2025-06-15 03:22:09 +00:00
WindowServer: Send key events to menu manager is there is a current menu
If there is a current menu, we now redirect all key events from window manager to the menu manager. This allows us to properly navigate a menu even when there is a current menu open. Menu key navigation is now a lot more pleasant to use :^) The action of pressing escape to close a menu has also been moved to its proper home in menu manager in this commit.
This commit is contained in:
parent
e6c826ffc3
commit
c66a6f131e
2 changed files with 17 additions and 14 deletions
|
@ -270,12 +270,21 @@ void WSMenuManager::event(CEvent& event)
|
|||
}
|
||||
}
|
||||
|
||||
if (event.type() == WSEvent::KeyDown) {
|
||||
for_each_active_menubar_menu([&](WSMenu& menu) {
|
||||
if (is_open(menu))
|
||||
menu.dispatch_event(event);
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
if (static_cast<WSEvent&>(event).is_key_event()) {
|
||||
auto& key_event = static_cast<const WSKeyEvent&>(event);
|
||||
|
||||
if (key_event.type() == WSEvent::KeyUp && key_event.key() == Key_Escape) {
|
||||
close_everyone();
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.type() == WSEvent::KeyDown) {
|
||||
for_each_active_menubar_menu([&](WSMenu& menu) {
|
||||
if (is_open(menu))
|
||||
menu.dispatch_event(event);
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return CObject::event(event);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue