diff --git a/src/states_screens/main_menu_screen.cpp b/src/states_screens/main_menu_screen.cpp index 688d130f1..acbf93237 100644 --- a/src/states_screens/main_menu_screen.cpp +++ b/src/states_screens/main_menu_screen.cpp @@ -405,7 +405,11 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name, } else if (selection == "quit") { +#ifdef ANDROID + ANativeActivity_finish(global_android_app->activity); +#else StateManager::get()->popMenu(); +#endif return; } else if (selection == "about") @@ -564,3 +568,15 @@ void MainMenuScreen::onDisabledItemClicked(const std::string& item) } #endif } // onDisabledItemClicked + +// ---------------------------------------------------------------------------- + +bool MainMenuScreen::onEscapePressed() +{ +#ifdef ANDROID + ANativeActivity_finish(global_android_app->activity); + return false; +#endif + + return true; +} // onEscapePressed diff --git a/src/states_screens/main_menu_screen.hpp b/src/states_screens/main_menu_screen.hpp index e6d8a861d..5b6cd6287 100644 --- a/src/states_screens/main_menu_screen.hpp +++ b/src/states_screens/main_menu_screen.hpp @@ -58,6 +58,10 @@ public: /** \brief implement callback from parent class GUIEngine::Screen */ virtual void onDisabledItemClicked(const std::string& item) OVERRIDE; + + /** \brief implement optional callback from parent + * class GUIEngine::Screen */ + virtual bool onEscapePressed() OVERRIDE; }; #endif diff --git a/src/states_screens/state_manager.cpp b/src/states_screens/state_manager.cpp index 86226f661..9d83e03f5 100644 --- a/src/states_screens/state_manager.cpp +++ b/src/states_screens/state_manager.cpp @@ -252,13 +252,9 @@ void StateManager::onTopMostScreenChanged() void StateManager::onStackEmptied() { - #ifdef ANDROID - ANativeActivity_finish(global_android_app->activity); - #else GUIEngine::cleanUp(); GUIEngine::deallocate(); main_loop->abort(); - #endif } // onStackEmptied // ============================================================================