diff options
author | Andreas Kling <kling@serenityos.org> | 2020-04-24 17:24:09 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-24 17:24:09 +0200 |
commit | cbb3c7aade8ede8ad0bf12fd27925270daa10164 (patch) | |
tree | b488efc2efad8b4c349905d37e57bbf632630b99 /Servers/WindowServer | |
parent | 4218b00cb4a2e969a8b768a85078b05bddf0479e (diff) | |
download | serenity-cbb3c7aade8ede8ad0bf12fd27925270daa10164.zip |
WindowServer: Skip over disabled menu items during keyboard navigation
Diffstat (limited to 'Servers/WindowServer')
-rw-r--r-- | Servers/WindowServer/Menu.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Servers/WindowServer/Menu.cpp b/Servers/WindowServer/Menu.cpp index 64b8720716..b5e0e9d533 100644 --- a/Servers/WindowServer/Menu.cpp +++ b/Servers/WindowServer/Menu.cpp @@ -406,12 +406,15 @@ void Menu::event(Core::Event& event) if (is_scrollable() && m_hovered_item_index == 0) return; + auto original_index = m_hovered_item_index; do { if (m_hovered_item_index == 0) m_hovered_item_index = m_items.size() - 1; else --m_hovered_item_index; - } while (hovered_item()->type() == MenuItem::Separator); + if (m_hovered_item_index == original_index) + return; + } while (hovered_item()->type() == MenuItem::Separator || !hovered_item()->is_enabled()); ASSERT(m_hovered_item_index >= 0 && m_hovered_item_index <= static_cast<int>(m_items.size()) - 1); @@ -428,12 +431,15 @@ void Menu::event(Core::Event& event) if (is_scrollable() && m_hovered_item_index == static_cast<int>(m_items.size()) - 1) return; + auto original_index = m_hovered_item_index; do { if (m_hovered_item_index == static_cast<int>(m_items.size()) - 1) m_hovered_item_index = 0; else ++m_hovered_item_index; - } while (hovered_item()->type() == MenuItem::Separator); + if (m_hovered_item_index == original_index) + return; + } while (hovered_item()->type() == MenuItem::Separator || !hovered_item()->is_enabled()); ASSERT(m_hovered_item_index >= 0 && m_hovered_item_index <= static_cast<int>(m_items.size()) - 1); |