mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 13:37:44 +00:00
WindowServer: make menus wrap vertically
This commit adds vertical wrap to menus. The first item is focused if Key_Down is pressed on the last item and the last item is focused if Key_up is pressed on the first item.
This commit is contained in:
parent
4a36a51618
commit
5aa37f6f5c
1 changed files with 10 additions and 4 deletions
|
@ -393,8 +393,11 @@ void WSMenu::event(CEvent& event)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (m_hovered_item_index <= 0)
|
if (m_hovered_item_index == 0)
|
||||||
|
m_hovered_item_index = m_items.size() - 1;
|
||||||
|
else if (m_hovered_item_index < 0)
|
||||||
return;
|
return;
|
||||||
|
else
|
||||||
--m_hovered_item_index;
|
--m_hovered_item_index;
|
||||||
} while (hovered_item()->type() == WSMenuItem::Separator);
|
} while (hovered_item()->type() == WSMenuItem::Separator);
|
||||||
|
|
||||||
|
@ -412,8 +415,11 @@ void WSMenu::event(CEvent& event)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (m_hovered_item_index >= m_items.size() - 1)
|
if (m_hovered_item_index == m_items.size() - 1)
|
||||||
|
m_hovered_item_index = 0;
|
||||||
|
else if (m_hovered_item_index > m_items.size() - 1)
|
||||||
return;
|
return;
|
||||||
|
else
|
||||||
++m_hovered_item_index;
|
++m_hovered_item_index;
|
||||||
} while (hovered_item()->type() == WSMenuItem::Separator);
|
} while (hovered_item()->type() == WSMenuItem::Separator);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue