mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-21 05:51:45 +08:00
fix(tabview): emit LV_EVENT_VALUE_CHANGED on header-button taps (#8537)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user