Crash when pressing [ENTER] in a menu when nothing is selected

This commit is contained in:
Bertrand Songis
2020-03-04 11:15:54 +01:00
parent a37ac5ebea
commit 3ea15c5586
+7 -2
View File
@@ -42,8 +42,13 @@ void MenuBody::onEvent(event_t event)
select(selectedIndex == 0 ? lines.size() - 1 : selectedIndex - 1);
}
else if (event == EVT_KEY_BREAK(KEY_ENTER)) {
Window::onEvent(event); // the window above will be closed on event
lines[selectedIndex].onPress();
if (selectedIndex < 0) {
select(0);
}
else {
Window::onEvent(event); // the window above will be closed on event
lines[selectedIndex].onPress();
}
}
else if (event == EVT_KEY_BREAK(KEY_EXIT)) {
if (onCancel)