mirror of
https://github.com/lvgl/lvgl.git
synced 2025-02-04 07:13:00 +08:00
Merge pull request #700 from joltwallet/list_fix
bug fix: initialize list size to 0; feature: select first added item …
This commit is contained in:
commit
9c675a8e82
@ -91,6 +91,7 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
ext->styles_btn[LV_BTN_STATE_INA] = &lv_style_btn_ina;
|
ext->styles_btn[LV_BTN_STATE_INA] = &lv_style_btn_ina;
|
||||||
ext->anim_time = LV_LIST_FOCUS_TIME;
|
ext->anim_time = LV_LIST_FOCUS_TIME;
|
||||||
ext->single_mode = false;
|
ext->single_mode = false;
|
||||||
|
ext->size = 0;
|
||||||
|
|
||||||
#if USE_LV_GROUP
|
#if USE_LV_GROUP
|
||||||
ext->last_sel = NULL;
|
ext->last_sel = NULL;
|
||||||
@ -227,6 +228,16 @@ lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt,
|
|||||||
lv_obj_set_width(label, liste->coords.x2 - label->coords.x1 - btn_hor_pad);
|
lv_obj_set_width(label, liste->coords.x2 - label->coords.x1 - btn_hor_pad);
|
||||||
if(label_signal == NULL) label_signal = lv_obj_get_signal_func(label);
|
if(label_signal == NULL) label_signal = lv_obj_get_signal_func(label);
|
||||||
}
|
}
|
||||||
|
#if USE_LV_GROUP
|
||||||
|
/* If this is the first item to be added to the list and the list is
|
||||||
|
* focussed, select it */
|
||||||
|
{
|
||||||
|
lv_group_t *g = lv_obj_get_group(list);
|
||||||
|
if(ext->size == 1 && lv_group_get_focused(g) == list) {
|
||||||
|
lv_list_set_btn_selected(list, liste);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return liste;
|
return liste;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user