Description
I require some guidance on how to use groups in the context with tabs
What MCU/Processor/Board and compiler are you using?
M5Stack - esp32
What do you want to achieve?
I have 3 tabs. Each tab has a set of controls in a groups. Only one tab is visible at a time. When I use the keypap / encoder to get to the next group it selects groups that are on the non-visible tabs. I would like to know what is the best approach to ensure that going to the next or previous group only navigates to the groups on the active tab.
Is this possible?
What have you tried so far?
in the group_focus_cb, I have tried to figure out which tab I am in and simulate button push but its pretty ugly
Code to reproduce
static void group_focus_cb(lv_group_t* group)
{
if (lv_group_get_editing(group)) return;
int object_on_tab = 0;
lv_obj_t* current_focused_obj = lv_group_get_focused(group);
if (current_focused_obj == tab_view){
return;
}
lv_obj_t* current_tab = current_focused_obj;
do
{
if (current_tab == tab1)
{
object_on_tab = 0;
break;
}
if (current_tab == tab2)
{
object_on_tab = 1;
break;
}
if (current_tab == tab3)
{
object_on_tab = 2;
break;
}
current_tab = current_tab->par;
} while (current_tab);
printf("object is on tab=%d activeTabIndex =%d\n",object_on_tab,activeTabIndex);
if (object_on_tab != activeTabIndex) {
skip_to_next_group = 1;
}
}
static void my_event_cb(lv_obj_t* obj, lv_event_t event)
{
if (event == LV_EVENT_VALUE_CHANGED)
{
int* data = (int *)lv_event_get_data();
activeTabIndex = *data;
printf("activeTabIndex %d\n", activeTabIndex);
}
}