How to set a new event-callback for tabview

You should not change event cb for the internal tabview’s btns
( should not change tab_btnm_event_cb in file lv_tabview.c to another.)
Because it has many process in tab_btnm_event_cb for tabview’s btns.

But if you want to know tab’s name at current
when tabview is clicked,
you can run the following code.

  lv_obj_t* tabview = lv_tabview_create(lv_scr_act(), NULL);

    lv_obj_t *tab1 = lv_tabview_add_tab(tabview, "Tab 1");
    lv_obj_t *tab2 = lv_tabview_add_tab(tabview, "Tab 2");
    lv_obj_t *tab3 = lv_tabview_add_tab(tabview, "Tab 3");

    lv_obj_set_event_cb(tabview, [](lv_obj_t* tabview, lv_event_t event){
      if(event != LV_EVENT_VALUE_CHANGED) return;
      lv_tabview_ext_t* ext = (lv_tabview_ext_t*) lv_obj_get_ext_attr(tabview);
      const char* tab_name = ext->tab_name_ptr[lv_tabview_get_tab_act(tabview)];
      printf("Current Active Tab : %s\n", tab_name);
1 Like