Accessing an object inside a container

Description

What MCU/Processor/Board and compiler are you using?

STM32f407 custom

What LVGL version are you using?

8.0

What do you want to achieve?

Create an array of buttons, the ability to customize each of them (change the style) separately

What have you tried so far?

I tried the matrix of buttons, but I read that it is impossible. Having created an array in a container, I don’t know how to refer to a specific element in the container.
When I create one button, it has a name and by that I can refer to it. In the example below, the buttons are created by a loop, but I do not know the name of the object or a way to refer to a specific element of the container (specifically the buttons)
P.S. Sorry for my English

Code to reproduce

for example if you create an array of buttons from the example. How to address them individually to each? And how to handle the event for a specific button from the container

static void event_cb(lv_event_t * e)
{
    /*The original target of the event. Can be the buttons or the container*/
    lv_obj_t * target = lv_event_get_target(e);

    /*The current target is always the container as the event is added to it*/
    lv_obj_t * cont = lv_event_get_current_target(e);

    /*If container was clicked do nothing*/
    if(target == cont) return;

    /*Make the clicked buttons red*/
    lv_obj_set_style_bg_color(target, lv_palette_main(LV_PALETTE_RED), 0);
}

/**
 * Demonstrate event bubbling
 */
void lv_example_event_3(void)
{

    lv_obj_t * cont = lv_obj_create(lv_scr_act());
    lv_obj_set_size(cont, 290, 200);
    lv_obj_center(cont);
    lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_ROW_WRAP);

    uint32_t i;
    for(i = 0; i < 30; i++) {
        lv_obj_t * btn = lv_btn_create(cont);
        lv_obj_set_size(btn, 80, 50);
        lv_obj_add_flag(btn, LV_OBJ_FLAG_EVENT_BUBBLE);

        lv_obj_t * label = lv_label_create(btn);
        lv_label_set_text_fmt(label, "%d", i);
        lv_obj_center(label);
    }

    lv_obj_add_event_cb(cont, event_cb, LV_EVENT_CLICKED, NULL);
}

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

You can use lv_obj_get_child on the container to loop over the buttons.

Thanks this should help. I’ll try