summaryrefslogtreecommitdiff
path: root/Userland/Services/WindowServer/MenuManager.cpp
diff options
context:
space:
mode:
authorSergiy Stupar <owner@sestolab.pp.ua>2022-11-07 20:17:38 +0200
committerAndreas Kling <kling@serenityos.org>2022-11-08 11:48:37 +0100
commit288d75fdabf161cc47d7326d63334702969673ae (patch)
tree578d18222fb1e01c3e56f257f9a7f4236826b058 /Userland/Services/WindowServer/MenuManager.cpp
parent892186d0585e18ad636a157e82f6f89f753dedcd (diff)
downloadserenity-288d75fdabf161cc47d7326d63334702969673ae.zip
WindowServer: Cycle through menu items with the same Alt shortcut
If there are multiple items with the same Alt shortcut, cycle through them with each keypress instead of activating immediately.
Diffstat (limited to 'Userland/Services/WindowServer/MenuManager.cpp')
-rw-r--r--Userland/Services/WindowServer/MenuManager.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/Userland/Services/WindowServer/MenuManager.cpp b/Userland/Services/WindowServer/MenuManager.cpp
index ad0750c637..83dbbe72ea 100644
--- a/Userland/Services/WindowServer/MenuManager.cpp
+++ b/Userland/Services/WindowServer/MenuManager.cpp
@@ -68,11 +68,12 @@ void MenuManager::event(Core::Event& event)
if (auto* shortcut_item_indices = m_current_menu->items_with_alt_shortcut(key_event.code_point())) {
VERIFY(!shortcut_item_indices->is_empty());
- // FIXME: If there are multiple items with the same Alt shortcut, we should cycle through them
- // with each keypress instead of activating immediately.
- auto index = shortcut_item_indices->at(0);
+ auto it = shortcut_item_indices->find_if([&](int const& i) { return i > m_current_menu->hovered_item_index(); });
+ auto index = shortcut_item_indices->at(it.is_end() ? 0 : it.index());
auto& item = m_current_menu->item(index);
m_current_menu->set_hovered_index(index);
+ if (shortcut_item_indices->size() > 1)
+ return;
if (item.is_submenu())
m_current_menu->descend_into_submenu_at_hovered_item();
else