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

lv_list: check the return value of btn events

This commit is contained in:
Gabor Kiss-Vamosi 2019-04-12 07:22:37 +02:00
parent 6a3c7d2b95
commit 6284e3a21b
3 changed files with 22 additions and 16 deletions

View File

@ -345,9 +345,10 @@ lv_res_t lv_obj_del(lv_obj_t * obj)
/*Delete from the group*/ /*Delete from the group*/
#if LV_USE_GROUP #if LV_USE_GROUP
bool was_focused = false; bool was_focused = false;
lv_group_t * group = lv_obj_get_group(obj);
if(obj->group_p) { if(group) {
if(lv_group_get_focused(obj->group_p) == obj) was_focused = true; if(lv_group_get_focused(group) == obj) was_focused = true;
lv_group_remove_obj(obj); lv_group_remove_obj(obj);
} }
#endif #endif
@ -390,7 +391,7 @@ lv_res_t lv_obj_del(lv_obj_t * obj)
} }
#if LV_USE_GROUP #if LV_USE_GROUP
if(was_focused) { if(indev->group == group && was_focused) {
lv_indev_reset(indev); lv_indev_reset(indev);
} }
#endif #endif
@ -2067,8 +2068,9 @@ static void delete_children(lv_obj_t * obj)
* LV_SIGNAL_DEFOCUS call*/ * LV_SIGNAL_DEFOCUS call*/
#if LV_USE_GROUP #if LV_USE_GROUP
bool was_focused = false; bool was_focused = false;
lv_group_t * group = lv_obj_get_group(obj);
if(obj->group_p) { if(group) {
if(lv_group_get_focused(obj->group_p) == obj) was_focused = true; if(lv_group_get_focused(obj->group_p) == obj) was_focused = true;
lv_group_remove_obj(obj); lv_group_remove_obj(obj);
} }
@ -2098,7 +2100,7 @@ static void delete_children(lv_obj_t * obj)
lv_indev_reset(indev); lv_indev_reset(indev);
} }
#if LV_USE_GROUP #if LV_USE_GROUP
if(was_focused) { if(indev->group == group && was_focused) {
lv_indev_reset(indev); lv_indev_reset(indev);
} }
#endif #endif

View File

@ -18,8 +18,8 @@
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/
#define LV_MEM_ADD_JUNK \ /*Add memory junk on alloc (0xaa) and free(0xbb) (just for testing purposes)*/
0 /*Add memory junk on alloc (0xaa) and free(0xbb) (just for testing purposes)*/ #define LV_MEM_ADD_JUNK 0
#ifdef LV_MEM_ENV64 #ifdef LV_MEM_ENV64
#define MEM_UNIT uint64_t #define MEM_UNIT uint64_t

View File

@ -745,20 +745,24 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
* button*/ * button*/
if(btn) { if(btn) {
if(sign == LV_SIGNAL_PRESSED) { if(sign == LV_SIGNAL_PRESSED) {
lv_event_send(btn, LV_EVENT_PRESSED, NULL); res = lv_event_send(btn, LV_EVENT_PRESSED, NULL);
} else if(sign == LV_SIGNAL_PRESSING) { } else if(sign == LV_SIGNAL_PRESSING) {
lv_event_send(btn, LV_EVENT_PRESSING, NULL); res = lv_event_send(btn, LV_EVENT_PRESSING, NULL);
} else if(sign == LV_SIGNAL_LONG_PRESS) { } else if(sign == LV_SIGNAL_LONG_PRESS) {
lv_event_send(btn, LV_EVENT_LONG_PRESSED, NULL); res = lv_event_send(btn, LV_EVENT_LONG_PRESSED, NULL);
} else if(sign == LV_SIGNAL_LONG_PRESS_REP) { } else if(sign == LV_SIGNAL_LONG_PRESS_REP) {
lv_event_send(btn, LV_EVENT_LONG_PRESSED_REPEAT, NULL); res = lv_event_send(btn, LV_EVENT_LONG_PRESSED_REPEAT, NULL);
} else if(sign == LV_SIGNAL_RELEASED) { } else if(sign == LV_SIGNAL_RELEASED) {
ext->last_sel = btn; ext->last_sel = btn;
if(indev->proc.long_pr_sent == 0) if(indev->proc.long_pr_sent == 0) {
lv_event_send(btn, LV_EVENT_SHORT_CLICKED, NULL); res = lv_event_send(btn, LV_EVENT_SHORT_CLICKED, NULL);
if(lv_indev_is_dragging(indev) == false) }
lv_event_send(btn, LV_EVENT_CLICKED, NULL); if(lv_indev_is_dragging(indev) == false && res == LV_RES_OK) {
lv_event_send(btn, LV_EVENT_RELEASED, NULL); res = lv_event_send(btn, LV_EVENT_CLICKED, NULL);
}
if(res == LV_RES_OK) {
res = lv_event_send(btn, LV_EVENT_RELEASED, NULL);
}
} }
} }
} }