Form navigation issue

This commit is contained in:
Bertrand Songis
2019-12-18 18:56:20 +01:00
parent ed664773b4
commit 98162c5729
+17 -5
View File
@@ -106,7 +106,8 @@ void FormGroup::setFocus(uint8_t flag)
first->setFocus(SET_FOCUS_FIRST); first->setFocus(SET_FOCUS_FIRST);
break; break;
case SET_FOCUS_BACKWARD: case SET_FOCUS_BACKWARD:
if (focusWindow == first) { // TODO this test should be recursive
if (focusWindow == first || focusWindow->getParent() == first) {
if (previous == this) if (previous == this)
last->setFocus(SET_FOCUS_BACKWARD); last->setFocus(SET_FOCUS_BACKWARD);
else if (previous) else if (previous)
@@ -117,6 +118,19 @@ void FormGroup::setFocus(uint8_t flag)
last->setFocus(SET_FOCUS_BACKWARD); last->setFocus(SET_FOCUS_BACKWARD);
} }
break; break;
case SET_FOCUS_FORWARD:
// TODO this test should be recursive
if (focusWindow == last || focusWindow->getParent() == last) {
if (next == this)
first->setFocus(SET_FOCUS_FORWARD);
else if (next)
next->setFocus(SET_FOCUS_FORWARD);
}
else {
if (first)
first->setFocus(SET_FOCUS_FORWARD);
}
break;
default: default:
if (focusWindow == previous) { if (focusWindow == previous) {
if (first) if (first)
@@ -124,7 +138,7 @@ void FormGroup::setFocus(uint8_t flag)
} }
else { else {
if (next) if (next)
next->setFocus(); next->setFocus(SET_FOCUS_FORWARD);
} }
break; break;
} }
@@ -140,11 +154,9 @@ void FormGroup::onEvent(event_t event)
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event); TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
if (event == EVT_KEY_BREAK(KEY_ENTER)) { if (event == EVT_KEY_BREAK(KEY_ENTER)) {
editMode = true;
first->setFocus(); first->setFocus();
} }
else if (event == EVT_KEY_BREAK(KEY_EXIT) && editMode) { else if (event == EVT_KEY_BREAK(KEY_EXIT) && !hasFocus()) {
editMode = false;
setFocus(SET_FOCUS_DEFAULT); setFocus(SET_FOCUS_DEFAULT);
} }
else { else {