What is the functional equivalent of lv_obj_allocate_ext_attr in v8?

In V7, you could store additional data in the extended area of an object, such as the below. What is the functional equivalent in v8?

typedef struct {
    lv_slider_ext_t slider;  //The ancestor slider structure
    int8_t index;           
    lv_obj_t * leftLabel; 
    lv_obj_t * label;  
} temp_slider_ext_t;

  lv_obj_allocate_ext_attr(slider, sizeof(temp_slider_ext_t));  //Re-alloacte the extended data
  temp_slider_ext_t * extSlider = (temp_slider_ext_t *)lv_obj_get_ext_attr(slider);
  extSlider->label = lblSlrRightValue;

Hi,

There is no direct replacement but you can do the followings:

  • use obj->user_data and free it in LV_EVENT_DELETE
  • add an event to object and store related in the last parameter of lv_obj_add_event_cb
  • create a new class. See how lv_slider extends lv_bar as an example here and here. If you only want to add new data it’s enough to set .instance_size = sizeof(temp_slider_t) and .base_class = &lv_slider_class.

Thanks for the response! I’ll have more v8 questions shortly :slight_smile:

1 Like