From f5b8dd17b81eebae6fdd53dd581e2f5075c7e08f Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 12 Feb 2019 22:48:39 +0100 Subject: [PATCH] lv_list_set_selected_btn fix --- lv_objx/lv_list.c | 5 +++-- lv_objx/lv_list.h | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lv_objx/lv_list.c b/lv_objx/lv_list.c index 8accb665a..48763d663 100644 --- a/lv_objx/lv_list.c +++ b/lv_objx/lv_list.c @@ -300,6 +300,7 @@ void lv_list_set_btn_selected(lv_obj_t * list, lv_obj_t * btn) } ext->selected_btn = btn; + ext->last_sel = btn; if(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); if(lv_group_get_editing(g)) { 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 */ 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); } else { 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 */ lv_list_set_btn_selected(list, ext->last_sel); } diff --git a/lv_objx/lv_list.h b/lv_objx/lv_list.h index 0fe0c1291..a31877082 100644 --- a/lv_objx/lv_list.h +++ b/lv_objx/lv_list.h @@ -59,8 +59,8 @@ typedef struct uint32_t size; /*the number of items(buttons) in the list*/ bool single_mode; /* whether single selected mode is enabled */ #if USE_LV_GROUP - lv_obj_t * last_sel; /* Last btn selected */ - lv_obj_t * selected_btn; + lv_obj_t * last_sel; /* The last selected button. It will be reverted when the list is focused again */ + lv_obj_t * selected_btn; /* The button is currently being selected*/ #endif } lv_list_ext_t;