mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 09:51:57 -05:00
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.
This commit is contained in:
parent
892186d058
commit
288d75fdab
2 changed files with 5 additions and 3 deletions
|
@ -105,6 +105,7 @@ public:
|
||||||
void redraw(MenuItem const&);
|
void redraw(MenuItem const&);
|
||||||
|
|
||||||
MenuItem* hovered_item() const;
|
MenuItem* hovered_item() const;
|
||||||
|
int hovered_item_index() const { return m_hovered_item_index; };
|
||||||
|
|
||||||
void set_hovered_index(int index, bool make_input = false);
|
void set_hovered_index(int index, bool make_input = false);
|
||||||
|
|
||||||
|
|
|
@ -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())) {
|
if (auto* shortcut_item_indices = m_current_menu->items_with_alt_shortcut(key_event.code_point())) {
|
||||||
VERIFY(!shortcut_item_indices->is_empty());
|
VERIFY(!shortcut_item_indices->is_empty());
|
||||||
// FIXME: If there are multiple items with the same Alt shortcut, we should cycle through them
|
auto it = shortcut_item_indices->find_if([&](int const& i) { return i > m_current_menu->hovered_item_index(); });
|
||||||
// with each keypress instead of activating immediately.
|
auto index = shortcut_item_indices->at(it.is_end() ? 0 : it.index());
|
||||||
auto index = shortcut_item_indices->at(0);
|
|
||||||
auto& item = m_current_menu->item(index);
|
auto& item = m_current_menu->item(index);
|
||||||
m_current_menu->set_hovered_index(index);
|
m_current_menu->set_hovered_index(index);
|
||||||
|
if (shortcut_item_indices->size() > 1)
|
||||||
|
return;
|
||||||
if (item.is_submenu())
|
if (item.is_submenu())
|
||||||
m_current_menu->descend_into_submenu_at_hovered_item();
|
m_current_menu->descend_into_submenu_at_hovered_item();
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Reference in a new issue