Skip to content

Commit fc319a4

Browse files
committed
lv_tabview: add lv_res_t return value to prevent tab laoding on LV_RES_INV
1 parent 4f11ad7 commit fc319a4

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lv_objx/lv_tabview.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,10 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, bool anim_en)
275275

276276
lv_style_t * style = lv_obj_get_style(ext->content);
277277

278+
lv_res_t res = LV_RES_OK;
278279
if(id >= ext->tab_cnt) id = ext->tab_cnt - 1;
279-
if(ext->tab_load_action && id != ext->tab_cur) ext->tab_load_action(tabview, id);
280+
if(ext->tab_load_action && id != ext->tab_cur) res = ext->tab_load_action(tabview, id);
281+
if(res != LV_RES_OK) return; /*Prevent the tab loading*/
280282

281283
ext->tab_cur = id;
282284

lv_objx/lv_tabview.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ extern "C" {
4242
* TYPEDEFS
4343
**********************/
4444

45-
/* parametes: pointer to a tabview object, tab_id*/
46-
typedef void (*lv_tabview_action_t)(lv_obj_t *, uint16_t);
45+
/* parametes: pointer to a tabview object, tab_id
46+
* return: LV_RES_INV: to prevent the loading of the tab; LV_RES_OK: if everything is fine*/
47+
typedef lv_res_t (*lv_tabview_action_t)(lv_obj_t *, uint16_t);
4748

4849

4950
enum {

0 commit comments

Comments
 (0)