[Table] Focus issue
This commit is contained in:
@@ -175,6 +175,9 @@ void Choice::openMenu()
|
||||
bool Choice::onTouchEnd(coord_t, coord_t)
|
||||
{
|
||||
if (enabled) {
|
||||
if (!hasFocus()) {
|
||||
setFocus(SET_FOCUS_DEFAULT);
|
||||
}
|
||||
onKeyPress();
|
||||
openMenu();
|
||||
}
|
||||
|
||||
+8
-1
@@ -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);
|
||||
|
||||
+38
-4
@@ -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<Table *>(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<Table *>(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);
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user