1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +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:
Gabor Kiss-Vamosi 2019-01-04 14:40:15 +01:00 committed by GitHub
commit 9c675a8e82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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->anim_time = LV_LIST_FOCUS_TIME;
ext->single_mode = false;
ext->size = 0;
#if USE_LV_GROUP
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);
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;
}