mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:38:12 +00:00
WindowManager: Fix default menu item on key down
This fixes the key down behavior on Terminal's Edit menu, which tried to hover the disabled menu item Copy if there was nothing selected.
This commit is contained in:
parent
f8cb068354
commit
e616cb35ba
1 changed files with 9 additions and 2 deletions
|
@ -391,9 +391,16 @@ void Menu::event(Core::Event& event)
|
|||
ASSERT(menu_window());
|
||||
ASSERT(menu_window()->is_visible());
|
||||
|
||||
// Default to the first item on key press if one has not been selected yet
|
||||
// Default to the first enabled, non-separator item on key press if one has not been selected yet
|
||||
if (!hovered_item()) {
|
||||
m_hovered_item_index = 0;
|
||||
int counter = 0;
|
||||
for (const auto& item : m_items) {
|
||||
if (item.type() != MenuItem::Separator && item.is_enabled()) {
|
||||
m_hovered_item_index = counter;
|
||||
break;
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
update_for_new_hovered_item(key == Key_Right);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue