Description
how to make some object to a group, then set the same event_cb?
What MCU/Processor/Board and compiler are you using?
What do you want to achieve?
for example, I create a page A, then it consists of several child objects such as labels, led, ect. Then I consider the page A(includes all child objects) as a group or a whole. If I click the whole, it should turn to open the page B, whether I clicked is the parent object(page A) or the child objects. How to achieve this effect?
Like the picture shown below, consider it as a page which consists of many labels, when I clicked the page(of course anywhere in the page, maybe click its child objects), if I clicked a child object, I prefer it call it’s parent object’s event_cb? how to achieve it easily.
What have you tried so far?
Code to reproduce
I haven’t code for this effect. But I try to express my thought by the C code below, I think it’s may be a little tedious.
The code block(s) should be formatted like:
static lv_obj_t* page_B;
static void Open_Page_B(lv_obj_t* obj, lv_event_t event)
{
/* open the page_B */
lv_obj_set_hidden(page_B, false);
}
void Create_Page_A(void)
{
lv_obj_t* page_A = lv_page_create(lv_scr_act(), NULL);
lv_obj_t* label1 = lv_label_create(page_A, NULL);
lv_obj_t* label2 = lv_label_create(page_A, NULL);
lv_obj_t* label3 = lv_label_create(page_A, NULL);
/* is here tedious? */
lv_obj_set_event_cb(page_A, Open_Page_B);
lv_obj_set_event_cb(label1, Open_Page_B);
lv_obj_set_event_cb(label2, Open_Page_B);
lv_obj_set_event_cb(label3, Open_Page_B);
}
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.