Website Summary Files Commits Branches @commit @diff @stats
path: root / src / ConsoleInterface / Menu.cpp
diff options
context:
space:
mode:
1 files changed, 9 insertions, 2 deletions
-rw-r--r--src/ConsoleInterface/Menu.cpp11
diff --git a/src/ConsoleInterface/Menu.cpp b/src/ConsoleInterface/Menu.cpp
index 4112ed2..07be42e 100644
--- a/src/ConsoleInterface/Menu.cpp
+++ b/src/ConsoleInterface/Menu.cpp
@@ -17,6 +17,14 @@ void Menu::addCommand(const Command& command) {
menuOptions.add(command);
}
+bool error = false;
+String errMessage;
+
+void Menu::registerError(const char* message) {
+ error = true;
+ errMessage = message;
+}
+
void Menu::navigate() const {
if (menuOptions.get_count() == 0) {
printLine("Menu is empty!");
@@ -24,7 +32,6 @@ void Menu::navigate() const {
}
unsigned buffer = 1; // We immedeately read the value of buffer, so this is fine
- bool error = false;
while (buffer != 0) {
printTitle(title);
@@ -35,7 +42,7 @@ void Menu::navigate() const {
printOrderedListElem(menuOptions[i].get_nameInMenu());
if (error) {
- printError("Invalid menu option!");
+ printError(errMessage.get_cstr());
error = false;
}