Fix bug where down arrow does nothing after clicking the main menu

This issue was previously fixed in 0c2ed71cdd, but that change added a bug that would trigger an infinite loop on scrolling in a list without any selectable items. Then 4fdbe81a13 restored the old behavior, reintroducing the issue.

This new fix does handle lists without any selectable items correctly.
This commit is contained in:
Chris Cowan 2024-08-10 20:27:12 -07:00 committed by Rachael Alexanderson
parent b79deabab1
commit faead1c733

View file

@ -188,11 +188,12 @@ class ListMenu : Menu
override bool MenuEvent (int mkey, bool fromcontroller)
{
int oldSelect = mDesc.mSelectedItem;
int startedAt = max(0, mDesc.mSelectedItem);
int startedAt;
switch (mkey)
{
case MKEY_Up:
startedAt = mDesc.mSelectedItem < 0 ? 0 : mDesc.mSelectedItem;
do
{
if (--mDesc.mSelectedItem < 0) mDesc.mSelectedItem = mDesc.mItems.Size()-1;
@ -203,6 +204,7 @@ class ListMenu : Menu
return true;
case MKEY_Down:
startedAt = mDesc.mSelectedItem < 0 ? mDesc.mItems.Size()-1 : mDesc.mSelectedItem;
do
{
if (++mDesc.mSelectedItem >= mDesc.mItems.Size()) mDesc.mSelectedItem = 0;