1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-26 01:06:16 +02:00

Implemented wrap around for context menu option selection

This commit is contained in:
Maarten ter Huurne 2013-08-11 23:50:20 +02:00
parent 76117663ff
commit 84fe36b5e8

View File

@ -147,10 +147,12 @@ bool ContextMenu::handleButtonPress(InputManager::Button button) {
dismiss();
break;
case InputManager::UP:
selected = std::max(0, selected - 1);
selected--;
if (selected < 0) selected = options.size() - 1;
break;
case InputManager::DOWN:
selected = std::min((int)options.size() - 1, selected + 1);
selected++;
if (selected >= static_cast<int>(options.size())) selected = 0;
break;
case InputManager::ACCEPT:
options[selected]->action();