Howto send SIGNAL to object under a layer that cover the page?


I create a page with some buttons on this page.
And create a new transparent layer
for receiving some signals to resize the page
by set this new layer to LV_PROTECT_PARENT | LV_PROTECT_PRESS_LOST …
and set the layer’s parent again back to the page’s bg.


( As the page’s property, the buttons’ parent is automatically
moved to the page’ scrollable-container.
But the layer’s parent is set back to the page’ bg container )

As this scenario
when draging signal occur,
I can receive some the layer’s signal to resize the page already.
But if the layer is pressed, I want to send this pressed-signal
from the layer to the buttons on the page
that under the layer too.

how to send this signal to the button under the layer?

Thank you.

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

  • ESP32

What do you want to achieve?

Send pressed signal on the layer that cover the page
to the button under the layer too.

What have you tried so far?

Code to reproduce

  lv_obj_t* page = lv_page_create(lv_scr_act(), NULL);
     lv_obj_set_size( page, 240,240);
     lv_page_set_scrl_layout( page, LV_LAYOUT_GRID);
     lv_obj_t* btn1  = lv_btn_create( page, NULL);
     lv_obj_t* btn2  = lv_btn_create( page, NULL);
     lv_obj_t* btn3  = lv_btn_create( page, NULL);
     lv_obj_t* layer = lv_cont_create( page, NULL);
       lv_obj_set_protect(layer, LV_PROTECT_PARENT | LV_PROTECT_PRESS_LOST  );
       lv_obj_set_parent(layer, page);
       lv_obj_set_style(layer, &lv_style_transp);
       lv_cont_set_fit( layer, LV_FIT_FLOOD);
       lv_obj_set_drag( layer, true);
       lv_obj_set_drag_throw( layer, true);
       lv_obj_align( layer, page, LV_ALIGN_CENTER,0,0);

static lv_res_t layer_signal(lv_obj_t * op_resizer, lv_signal_t sign, void * param)
   if( sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_PRESSING ) {
      ... // draging to change size of the page
      ... // how to send these signal to the buttons too ?

Screenshot and/or video

Already solved!

By recursive to get the button child from the page’s scrollable-container.
And send the event to it directly.

( However if any better way , please introduce . Thank you )

Have you tried lv_event_send?

Yes, I used the lv_event_send(…) directly to the button.

And do you search the button on the pressed coordinate manually?

Yes, at now recurvsively search pressed button manually,
do you mind to advice more better method?
If there is any better method,
I would like to use btnm instead of multiple buttons for saving memory.

do you mind to advice more better method?

I don’t know a really clean method because searching the pressed object happens internally and there is no nice public API for it.
However, it seems with a minimal modification indev_search_obj (lv_indev.c) can be made public. Only its first parameter should be a point instead of lv_indev_proc_t.
Then you could call indev_search_obj(page, &point) to get the object under a point.

If you tested this method (and it worked) could you send a PR with it?

Thank you for the advice.

Yes, I will try by indev_search_obj(..) method.
If it worked, I will send a PR.

1 Like

Already add a PR.

Another question.
If I change to use a button-matrix instead of the multiple btns on the page,
when I get a touched point from the transparent layer on top of the page
how to use this point for sending something like signal/event to the button of button-matrix ?

I have tried for sending LV_EVENT_CLICKED to btnm, but it doesn’t work.