1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-23 02:37:30 +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(); dismiss();
break; break;
case InputManager::UP: case InputManager::UP:
selected = std::max(0, selected - 1); selected--;
if (selected < 0) selected = options.size() - 1;
break; break;
case InputManager::DOWN: case InputManager::DOWN:
selected = std::min((int)options.size() - 1, selected + 1); selected++;
if (selected >= static_cast<int>(options.size())) selected = 0;
break; break;
case InputManager::ACCEPT: case InputManager::ACCEPT:
options[selected]->action(); options[selected]->action();