From be19e91e91649af2552fabd156173d6f10062964 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 24 Jun 2020 11:24:07 +0200 Subject: [PATCH] fix focusing/defocusing for pages --- src/lv_core/lv_indev.c | 13 +++++++------ src/lv_core/lv_obj.c | 2 -- src/lv_widgets/lv_page.c | 14 ++++++++++---- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/lv_core/lv_indev.c b/src/lv_core/lv_indev.c index cc2c608b6..a491c0996 100644 --- a/src/lv_core/lv_indev.c +++ b/src/lv_core/lv_indev.c @@ -1183,11 +1183,6 @@ static void indev_click_focus(lv_indev_proc_t * proc) } /*The object are not in the same group (in different group or one in not a group)*/ else { - /*Focus to the act. its group*/ - if(g_act) { - lv_group_focus_obj(indev_obj_act); - if(indev_reset_check(proc)) return; - } /*If the prev. obj. is not in a group then defocus it.*/ if(g_prev == NULL && proc->types.pointer.last_pressed) { lv_signal_send(proc->types.pointer.last_pressed, LV_SIGNAL_DEFOCUS, NULL); @@ -1213,12 +1208,18 @@ static void indev_click_focus(lv_indev_proc_t * proc) if(indev_reset_check(proc)) return; } } + } + /*Focus to the act. in its group*/ + if(g_act) { + lv_group_focus_obj(indev_obj_act); + if(indev_reset_check(proc)) return; + } else { lv_signal_send(indev_obj_act, LV_SIGNAL_FOCUS, NULL); if(indev_reset_check(proc)) return; lv_event_send(indev_obj_act, LV_EVENT_FOCUSED, NULL); if(indev_reset_check(proc)) return; - } + } } #else if(proc->types.pointer.last_pressed) { diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 2a1874a9e..8c4276e94 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -3752,7 +3752,6 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param) else if(sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) { lv_obj_clear_state(obj, LV_STATE_PRESSED); } -#if LV_USE_GROUP else if(sign == LV_SIGNAL_FOCUS) { if(lv_group_get_editing(lv_obj_get_group(obj))) { uint8_t state = LV_STATE_FOCUSED; @@ -3779,7 +3778,6 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param) lv_obj_clear_state(obj, LV_STATE_FOCUSED | LV_STATE_EDITED); } -#endif else if(sign == LV_SIGNAL_CLEANUP) { lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); } diff --git a/src/lv_widgets/lv_page.c b/src/lv_widgets/lv_page.c index 31a1fef13..f8141c320 100644 --- a/src/lv_widgets/lv_page.c +++ b/src/lv_widgets/lv_page.c @@ -1054,10 +1054,16 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi } } else if(sign == LV_SIGNAL_DEFOCUS) { - res = lv_signal_send(page, LV_SIGNAL_DEFOCUS, NULL); - if(res != LV_RES_OK) return res; - res = lv_event_send(page, LV_EVENT_DEFOCUSED, NULL); - if(res != LV_RES_OK) return res; + bool in_group = false; +#if LV_USE_GROUP + in_group = lv_obj_get_group(page) ? true : false; +#endif + if(in_group == false) { + res = lv_signal_send(page, LV_SIGNAL_DEFOCUS, NULL); + if(res != LV_RES_OK) return res; + res = lv_event_send(page, LV_EVENT_DEFOCUSED, NULL); + if(res != LV_RES_OK) return res; + } } else if(sign == LV_SIGNAL_CLEANUP) { page_ext->scrl = NULL;