1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

lv_list_set_selected_btn fix

This commit is contained in:
Gabor Kiss-Vamosi 2019-02-12 22:48:39 +01:00
parent fabd551e2a
commit f5b8dd17b8
2 changed files with 5 additions and 4 deletions

View File

@ -300,6 +300,7 @@ void lv_list_set_btn_selected(lv_obj_t * list, lv_obj_t * btn)
} }
ext->selected_btn = btn; ext->selected_btn = btn;
ext->last_sel = btn;
if(ext->selected_btn) { if(ext->selected_btn) {
lv_btn_state_t s = lv_btn_get_state(ext->selected_btn); lv_btn_state_t s = lv_btn_get_state(ext->selected_btn);
@ -760,7 +761,7 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
lv_group_t * g = lv_obj_get_group(list); lv_group_t * g = lv_obj_get_group(list);
if(lv_group_get_editing(g)) { if(lv_group_get_editing(g)) {
lv_list_ext_t * ext = lv_obj_get_ext_attr(list); lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
if(NULL != ext->last_sel) { if(ext->last_sel) {
/* Select the last used button */ /* Select the last used button */
lv_list_set_btn_selected(list, ext->last_sel); lv_list_set_btn_selected(list, ext->last_sel);
} }
@ -779,7 +780,7 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
lv_list_set_btn_selected(list, last_clicked_btn); lv_list_set_btn_selected(list, last_clicked_btn);
} else { } else {
lv_list_ext_t * ext = lv_obj_get_ext_attr(list); lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
if(NULL != ext->last_sel) { if(ext->last_sel) {
/* Select the last used button */ /* Select the last used button */
lv_list_set_btn_selected(list, ext->last_sel); lv_list_set_btn_selected(list, ext->last_sel);
} }

View File

@ -59,8 +59,8 @@ typedef struct
uint32_t size; /*the number of items(buttons) in the list*/ uint32_t size; /*the number of items(buttons) in the list*/
bool single_mode; /* whether single selected mode is enabled */ bool single_mode; /* whether single selected mode is enabled */
#if USE_LV_GROUP #if USE_LV_GROUP
lv_obj_t * last_sel; /* Last btn selected */ lv_obj_t * last_sel; /* The last selected button. It will be reverted when the list is focused again */
lv_obj_t * selected_btn; lv_obj_t * selected_btn; /* The button is currently being selected*/
#endif #endif
} lv_list_ext_t; } lv_list_ext_t;