diff --git a/src/widgets/tabview/lv_tabview.c b/src/widgets/tabview/lv_tabview.c index ab114d2589..165d43f073 100644 --- a/src/widgets/tabview/lv_tabview.c +++ b/src/widgets/tabview/lv_tabview.c @@ -305,8 +305,23 @@ static void button_clicked_event_cb(lv_event_t * e) lv_obj_t * button = lv_event_get_current_target(e); lv_obj_t * tv = lv_obj_get_parent(lv_obj_get_parent(button)); - int32_t idx = lv_obj_get_index_by_type(button, &lv_button_class); + + if(tv == NULL) return; + + /* Remember currently active tab before the click */ + uint32_t prev_idx = lv_tabview_get_tab_active(tv); + + /* Index of the button that was clicked */ + uint32_t idx = lv_obj_get_index_by_type(button, &lv_button_class); + + /* Switch to the requested tab */ lv_tabview_set_active(tv, idx, LV_ANIM_OFF); + + /* If the tab really changed, notify listeners just like the + * swipe/scroll handler does. */ + if(prev_idx != idx) { + lv_obj_send_event(tv, LV_EVENT_VALUE_CHANGED, NULL); + } } static void cont_scroll_end_event_cb(lv_event_t * e)