Tabs with groups

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);
    }
}

It was already asked a few times but unfortunately, there still is no ready-to-use solution for it. When I needed this I added the objects (lv_obj_t * variables) to 3 structs according to the 3 tabs and used the LV_EVENT_VALUE_CHANGES event of the tabview to remove all object from the group, and add the object of the current tab.

Thanks @kisvegabor That is helpful.
Are you using something like this?

lv_obj_t ** obj;
LL_READ(g1->obj_ll, obj) {
    lv_obj_del(*obj);
} 

Do you have a small code sample?

I also applied this technique in a new demo for v7.0. It’s not finished the part you need already works.

excellent!. Thank you

You are welcome! :slight_smile: