diff --git a/radio/src/thirdparty/libopenui/src/choice.cpp b/radio/src/thirdparty/libopenui/src/choice.cpp index f7f55af44..75ba22579 100644 --- a/radio/src/thirdparty/libopenui/src/choice.cpp +++ b/radio/src/thirdparty/libopenui/src/choice.cpp @@ -175,6 +175,9 @@ void Choice::openMenu() bool Choice::onTouchEnd(coord_t, coord_t) { if (enabled) { + if (!hasFocus()) { + setFocus(SET_FOCUS_DEFAULT); + } onKeyPress(); openMenu(); } diff --git a/radio/src/thirdparty/libopenui/src/expansion_panel.cpp b/radio/src/thirdparty/libopenui/src/expansion_panel.cpp index a73e098c9..53ef22fe4 100644 --- a/radio/src/thirdparty/libopenui/src/expansion_panel.cpp +++ b/radio/src/thirdparty/libopenui/src/expansion_panel.cpp @@ -39,7 +39,14 @@ void ExpansionPanelHeader::onEvent(event_t event) panel->toggle(); } else if (event == EVT_ROTARY_RIGHT && !panel->isOpen) { - panel->getNextField()->setFocus(SET_FOCUS_FORWARD); + auto next = panel->getNextField(); + if (next) + next->setFocus(SET_FOCUS_FORWARD); + } + else if (event == EVT_ROTARY_LEFT) { + auto previous = panel->getPreviousField(); + if (previous) + previous->setFocus(SET_FOCUS_BACKWARD); } else { FormGroup::onEvent(event); diff --git a/radio/src/thirdparty/libopenui/src/table.cpp b/radio/src/thirdparty/libopenui/src/table.cpp index b64a31c0b..0a628fbea 100644 --- a/radio/src/thirdparty/libopenui/src/table.cpp +++ b/radio/src/thirdparty/libopenui/src/table.cpp @@ -102,12 +102,46 @@ void Table::Body::onEvent(event_t event) } } if (event == EVT_ROTARY_RIGHT) { - if (!lines.empty()) - select((selection + 1) % lines.size(), true); + auto table = static_cast(parent); + if (table->windowFlags & FORWARD_SCROLL) { + auto index = selection + 1; + if (index < int(lines.size())) { + select(index, true); + } + else { + auto next = table->getNextField(); + if (next) { + select(-1, false); + next->setFocus(SET_FOCUS_FORWARD); + } + } + } + else { + if (!lines.empty()) { + select((selection + 1) % lines.size(), true); + } + } } else if (event == EVT_ROTARY_LEFT) { - if (!lines.empty()) - select(selection <= 0 ? lines.size() - 1 : selection - 1, true); + auto table = static_cast
(parent); + if (table->windowFlags & FORWARD_SCROLL) { + auto index = selection - 1; + if (index >= 0) { + select(index, true); + } + else { + auto previous = table->getPreviousField(); + if (previous) { + select(-1, false); + previous->setFocus(SET_FOCUS_BACKWARD); + } + } + } + else { + if (!lines.empty()) { + select(selection <= 0 ? lines.size() - 1 : selection - 1, true); + } + } } else if (event == EVT_KEY_BREAK(KEY_EXIT) && selection >= 0) { select(-1, true); diff --git a/radio/src/thirdparty/libopenui/src/table.h b/radio/src/thirdparty/libopenui/src/table.h index 4cbcff089..75f5f3bd3 100644 --- a/radio/src/thirdparty/libopenui/src/table.h +++ b/radio/src/thirdparty/libopenui/src/table.h @@ -283,7 +283,7 @@ class Table: public FormField { void setFocus(uint8_t flag) override { if (body.selection < 0 && !body.lines.empty()) { - select(0); + select(flag == SET_FOCUS_BACKWARD ? body.lines.size() - 1 : 0); } body.setFocus(flag); }