Skip to content

Commit

Permalink
Fix bug where down arrow does nothing after clicking the main menu
Browse files Browse the repository at this point in the history
This issue was previously fixed in 0c2ed71, but that change added a bug that would trigger an infinite loop on scrolling in a list without any selectable items. Then 4fdbe81 restored the old behavior, reintroducing the issue.

This new fix does handle lists without any selectable items correctly.
  • Loading branch information
Macil authored and madame-rachelle committed Sep 16, 2024
1 parent b79deab commit faead1c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion wadsrc/static/zscript/engine/ui/menu/listmenu.zs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit faead1c

Please sign in to comment.