Form navigation fix

This commit is contained in:
Bertrand Songis
2020-05-15 12:46:57 +02:00
parent c4164e8302
commit c07b28d3cc
2 changed files with 30 additions and 9 deletions
+27 -9
View File
@@ -129,20 +129,32 @@ void FormGroup::setFocus(uint8_t flag)
if (windowFlags & FORM_FORWARD_FOCUS) { if (windowFlags & FORM_FORWARD_FOCUS) {
switch (flag) { switch (flag) {
case SET_FOCUS_FIRST: case SET_FOCUS_FIRST:
if (first) if (first) {
first->setFocus(SET_FOCUS_FIRST); first->setFocus(SET_FOCUS_FIRST);
}
else if (next) {
next->setFocus(SET_FOCUS_FIRST);
}
break; break;
case SET_FOCUS_BACKWARD: case SET_FOCUS_BACKWARD:
if (focusWindow->isChild(first)) { if (focusWindow->isChild(first)) {
if (previous == this) if (previous == this) {
last->setFocus(SET_FOCUS_BACKWARD); last->setFocus(SET_FOCUS_BACKWARD);
else if (previous) }
else if (previous) {
previous->setFocus(SET_FOCUS_BACKWARD); previous->setFocus(SET_FOCUS_BACKWARD);
}
} }
else { else {
if (last) if (last) {
last->setFocus(SET_FOCUS_BACKWARD); last->setFocus(SET_FOCUS_BACKWARD);
}
else if (previous) {
clearFocus();
focusWindow = this;
previous->setFocus(SET_FOCUS_BACKWARD);
}
} }
break; break;
@@ -151,24 +163,30 @@ void FormGroup::setFocus(uint8_t flag)
if (next == this) { if (next == this) {
first->setFocus(SET_FOCUS_FORWARD); first->setFocus(SET_FOCUS_FORWARD);
} }
else if (next) else if (next) {
next->setFocus(SET_FOCUS_FORWARD); next->setFocus(SET_FOCUS_FORWARD);
}
} }
else { else {
if (first) { if (first) {
first->setFocus(SET_FOCUS_FORWARD); first->setFocus(SET_FOCUS_FORWARD);
} }
else if (next) {
clearFocus();
focusWindow = this;
next->setFocus(SET_FOCUS_FORWARD);
}
} }
break; break;
default: default:
if (focusWindow == previous) { if (focusWindow == previous) {
if (first) if (first) {
first->setFocus(SET_FOCUS_DEFAULT); first->setFocus(SET_FOCUS_DEFAULT);
}
} }
else { else if (next) {
if (next) next->setFocus(SET_FOCUS_FORWARD);
next->setFocus(SET_FOCUS_FORWARD);
} }
break; break;
} }
+3
View File
@@ -124,6 +124,9 @@ class FormGroup: public FormField {
Window::clear(); Window::clear();
first = nullptr; first = nullptr;
last = nullptr; last = nullptr;
if (previous && (windowFlags & FORM_FORWARD_FOCUS)) {
previous->setNextField(this);
}
} }
void setFocus(uint8_t flag) override; void setFocus(uint8_t flag) override;