From c07b28d3cc8d2f163579d9bccb898652663e347a Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Fri, 15 May 2020 12:46:57 +0200 Subject: [PATCH] Form navigation fix --- radio/src/thirdparty/libopenui/src/form.cpp | 36 +++++++++++++++------ radio/src/thirdparty/libopenui/src/form.h | 3 ++ 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/radio/src/thirdparty/libopenui/src/form.cpp b/radio/src/thirdparty/libopenui/src/form.cpp index 33346d33c..9c76b458c 100644 --- a/radio/src/thirdparty/libopenui/src/form.cpp +++ b/radio/src/thirdparty/libopenui/src/form.cpp @@ -129,20 +129,32 @@ void FormGroup::setFocus(uint8_t flag) if (windowFlags & FORM_FORWARD_FOCUS) { switch (flag) { case SET_FOCUS_FIRST: - if (first) + if (first) { first->setFocus(SET_FOCUS_FIRST); + } + else if (next) { + next->setFocus(SET_FOCUS_FIRST); + } break; case SET_FOCUS_BACKWARD: if (focusWindow->isChild(first)) { - if (previous == this) + if (previous == this) { last->setFocus(SET_FOCUS_BACKWARD); - else if (previous) + } + else if (previous) { previous->setFocus(SET_FOCUS_BACKWARD); + } } else { - if (last) + if (last) { last->setFocus(SET_FOCUS_BACKWARD); + } + else if (previous) { + clearFocus(); + focusWindow = this; + previous->setFocus(SET_FOCUS_BACKWARD); + } } break; @@ -151,24 +163,30 @@ void FormGroup::setFocus(uint8_t flag) if (next == this) { first->setFocus(SET_FOCUS_FORWARD); } - else if (next) + else if (next) { next->setFocus(SET_FOCUS_FORWARD); + } } else { if (first) { first->setFocus(SET_FOCUS_FORWARD); } + else if (next) { + clearFocus(); + focusWindow = this; + next->setFocus(SET_FOCUS_FORWARD); + } } break; default: if (focusWindow == previous) { - if (first) + if (first) { first->setFocus(SET_FOCUS_DEFAULT); + } } - else { - if (next) - next->setFocus(SET_FOCUS_FORWARD); + else if (next) { + next->setFocus(SET_FOCUS_FORWARD); } break; } diff --git a/radio/src/thirdparty/libopenui/src/form.h b/radio/src/thirdparty/libopenui/src/form.h index d326d846e..3bb9b8af5 100644 --- a/radio/src/thirdparty/libopenui/src/form.h +++ b/radio/src/thirdparty/libopenui/src/form.h @@ -124,6 +124,9 @@ class FormGroup: public FormField { Window::clear(); first = nullptr; last = nullptr; + if (previous && (windowFlags & FORM_FORWARD_FOCUS)) { + previous->setNextField(this); + } } void setFocus(uint8_t flag) override;