From 84fe36b5e82cb897cf0a1fd1b7bdcd4612db4103 Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Sun, 11 Aug 2013 23:50:20 +0200 Subject: [PATCH] Implemented wrap around for context menu option selection --- src/contextmenu.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/contextmenu.cpp b/src/contextmenu.cpp index acfdde9..03f8abe 100644 --- a/src/contextmenu.cpp +++ b/src/contextmenu.cpp @@ -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(options.size())) selected = 0; break; case InputManager::ACCEPT: options[selected]->action();