diff --git a/src/LiquidMenu.h b/src/LiquidMenu.h index 2eac4b2..1424237 100644 --- a/src/LiquidMenu.h +++ b/src/LiquidMenu.h @@ -1186,6 +1186,12 @@ class LiquidSystem /// Switches to the next screen. void next_screen(); + /** + * @brief Change to the next screen + * @return Whether we change the screen correctly or not + */ + bool changeToNextScreen(); + /// Switches to the next screen. /** @note Prefix increment operator overloading. diff --git a/src/LiquidSystem.cpp b/src/LiquidSystem.cpp index b647d6b..8bb3990 100644 --- a/src/LiquidSystem.cpp +++ b/src/LiquidSystem.cpp @@ -116,6 +116,27 @@ void LiquidSystem::next_screen() { _p_liquidMenu[_currentMenu]->next_screen(); } +bool LiquidSystem::changeToNextScreen() +{ + LiquidScreen *currentScreen = _p_liquidMenu[_currentMenu]->get_currentScreen(); + if (currentScreen->get_next_screen() == NULL) + { + if (currentScreen->get_next_menu()) + { + change_menu(*currentScreen->get_next_menu(), true); + return true; + } + } + else + { + change_menu(*currentScreen->get_next_menu(), false); + change_screen(currentScreen->get_next_screen()); + return true; + } + + return false; +} + void LiquidSystem::operator++() { next_screen(); }