Focus fixes

This commit is contained in:
Bertrand Songis
2020-10-09 17:03:30 +02:00
parent 1565a7a8e4
commit 8d27a510a4
3 changed files with 24 additions and 25 deletions
+3 -3
View File
@@ -74,10 +74,10 @@ class ExpansionPanel: public FormGroup {
void setFocus(uint8_t flag) override void setFocus(uint8_t flag) override
{ {
if (!isOpen) if (isOpen)
header->setFocus(flag);
else
FormGroup::setFocus(flag); FormGroup::setFocus(flag);
else
header->setFocus(flag);
} }
FormGroup * body = nullptr; FormGroup * body = nullptr;
+19 -20
View File
@@ -63,18 +63,22 @@ void FormField::onEvent(event_t event)
void FormField::setFocus(uint8_t flag) void FormField::setFocus(uint8_t flag)
{ {
if (!enabled) { if (enabled) {
if (flag == SET_FOCUS_BACKWARD) { Window::setFocus(flag);
if (previous)
previous->setFocus(flag);
}
else {
if (next)
next->setFocus(flag);
}
} }
else { else {
Window::setFocus(flag); clearFocus();
focusWindow = this;
if (flag == SET_FOCUS_BACKWARD) {
if (previous) {
previous->setFocus(flag);
}
}
else {
if (next) {
next->setFocus(flag);
}
}
} }
} }
@@ -133,15 +137,6 @@ void FormGroup::setFocus(uint8_t flag)
if (windowFlags & FORM_FORWARD_FOCUS) { if (windowFlags & FORM_FORWARD_FOCUS) {
switch (flag) { switch (flag) {
case SET_FOCUS_FIRST:
if (first) {
first->setFocus(SET_FOCUS_FIRST);
}
else if (next) {
next->setFocus(SET_FOCUS_FIRST);
}
break;
case SET_FOCUS_BACKWARD: case SET_FOCUS_BACKWARD:
if (focusWindow->isChild(first)) { if (focusWindow->isChild(first)) {
if (previous == this) { if (previous == this) {
@@ -163,8 +158,12 @@ void FormGroup::setFocus(uint8_t flag)
} }
break; break;
case SET_FOCUS_FIRST:
clearFocus();
// no break;
case SET_FOCUS_FORWARD: case SET_FOCUS_FORWARD:
if (focusWindow->isChild(this)) { if (focusWindow && focusWindow->isChild(this)) {
if (next == this) { if (next == this) {
first->setFocus(SET_FOCUS_FORWARD); first->setFocus(SET_FOCUS_FORWARD);
} }
+2 -2
View File
@@ -62,9 +62,9 @@ class FormField: public Window {
editMode = newEditMode; editMode = newEditMode;
} }
void enable(bool enabled = true) void enable(bool value = true)
{ {
this->enabled = enabled; enabled = value;
invalidate(); invalidate();
} }