diff --git a/src/gmenu2x.cpp b/src/gmenu2x.cpp index 6cdc1d5..ce620ad 100644 --- a/src/gmenu2x.cpp +++ b/src/gmenu2x.cpp @@ -636,6 +636,9 @@ void GMenu2X::mainLoop() { gotEvent = input.getButton(&button, wait); } while (wait && !gotEvent); if (gotEvent) { + if (button == InputManager::QUIT) { + break; + } for (auto it = layers.rbegin(); it != layers.rend(); ++it) { if ((*it)->handleButtonPress(button)) { break; diff --git a/src/inputmanager.cpp b/src/inputmanager.cpp index e4f66fd..85535aa 100644 --- a/src/inputmanager.cpp +++ b/src/inputmanager.cpp @@ -275,6 +275,10 @@ bool InputManager::getButton(Button *button, bool wait) { *button = REPAINT; return true; + case SDL_QUIT: + *button = QUIT; + return true; + default: return false; } diff --git a/src/inputmanager.h b/src/inputmanager.h index a59401d..33f6146 100644 --- a/src/inputmanager.h +++ b/src/inputmanager.h @@ -58,7 +58,9 @@ public: ACCEPT, CANCEL, ALTLEFT, ALTRIGHT, MENU, SETTINGS, - REPAINT, + // Events that are not actually buttons: + // (not included in BUTTON_TYPE_SIZE) + REPAINT, QUIT, }; #define BUTTON_TYPE_SIZE 10