1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-25 02:58:02 +02:00

Wrap-around menu selection

This commit is contained in:
Brian Fiete 2020-10-07 11:05:35 -07:00
parent 5a60d0e2d5
commit 557b13070c
2 changed files with 13 additions and 5 deletions

View file

@ -528,6 +528,8 @@ namespace Beefy.widgets
SetSelection(0); SetSelection(0);
break; break;
} }
else if ((mSelectIdx == 0) && (!mItemWidgets.IsEmpty))
SetSelection(mItemWidgets.Count - 1);
else if (mSelectIdx > 0) else if (mSelectIdx > 0)
SetSelection(mSelectIdx - 1); SetSelection(mSelectIdx - 1);
break; break;
@ -539,6 +541,8 @@ namespace Beefy.widgets
} }
else if (mSelectIdx < mItemWidgets.Count - 1) else if (mSelectIdx < mItemWidgets.Count - 1)
SetSelection(mSelectIdx + 1); SetSelection(mSelectIdx + 1);
else
SetSelection(0);
break; break;
case .Return: case .Return:
SubmitSelection(); SubmitSelection();

View file

@ -650,12 +650,16 @@ namespace IDE.ui
public void SelectDirection(int32 dir) public void SelectDirection(int32 dir)
{ {
if (mEntryList.IsEmpty)
return;
int32 newSelection = mSelectIdx + dir; int32 newSelection = mSelectIdx + dir;
if ((newSelection >= 0) && (newSelection < mEntryList.Count)) if (newSelection < 0)
{ newSelection = (.)mEntryList.Count - 1;
if (mEntryList[newSelection].mShowIdx != -1) else if (newSelection >= mEntryList.Count)
Select(newSelection); newSelection = 0;
}
if (mEntryList[newSelection].mShowIdx != -1)
Select(newSelection);
} }
public override void ScrollPositionChanged() public override void ScrollPositionChanged()