Why aren't signal and design callbacks copied in lv_*_create?

in lv_obj.c there’s a comment that these aren’t copied from copy to parent, but whats the justification for this? If I make a custom lv_btn with a different signal handler, I’d expect that my copy would have the same signal handler.


The comment says

   /*Only copy the `event_cb`. `signal_cb` and `design_cb` will be copied in the derived
    * object type (e.g. `lv_btn`)*/

Let’s say you copy an lv_page First an lv_obj is create. If it’d copy the signal function and lv_obj_create calls e.g. lv_obj_set_size LV_SIGNAL_COORDS_CHG would be sent to the lv_page_signal. But at this point we are still far from having an lv_page because still only lv_obj is being created.

Therefore the create functions set their own signal/design functions when they created everything needed.

Here you can see how/where lv_page_create sets the signal functions. So the copy will have the correct signal function:

1 Like