From 0ee104d155b1e416dde827ef6126033487236528 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 12 Oct 2018 09:09:10 +0200 Subject: [PATCH] lv_btnm: ignore clicks on inactive buttons --- lv_objx/lv_btnm.c | 53 ++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/lv_objx/lv_btnm.c b/lv_objx/lv_btnm.c index c5f609213..38f011091 100644 --- a/lv_objx/lv_btnm.c +++ b/lv_objx/lv_btnm.c @@ -547,45 +547,42 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param) } } else if(sign == LV_SIGNAL_RELEASED) { if(ext->btn_id_pr != LV_BTNM_PR_NONE) { - if(ext->action) { - uint16_t txt_i = get_button_text(btnm, ext->btn_id_pr); - if(txt_i != LV_BTNM_PR_NONE && button_is_inactive(ext->map_p[txt_i]) == false) { - ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i])); - } - } + uint16_t txt_i = get_button_text(btnm, ext->btn_id_pr); + if(button_is_inactive(ext->map_p[txt_i]) == false && txt_i != LV_BTNM_PR_NONE) { /*Ignore the inactive buttons anf click between the buttons*/ + if(ext->action)ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i])); - /*Invalidate to old pressed area*/; - lv_obj_get_coords(btnm, &btnm_area); - lv_area_copy(&btn_area, &ext->button_areas[ext->btn_id_pr]); - btn_area.x1 += btnm_area.x1; - btn_area.y1 += btnm_area.y1; - btn_area.x2 += btnm_area.x1; - btn_area.y2 += btnm_area.y1; - lv_inv_area(&btn_area); - - if(ext->toggle != 0) { - /*Invalidate to old toggled area*/; - lv_area_copy(&btn_area, &ext->button_areas[ext->btn_id_tgl]); + /*Invalidate to old pressed area*/; + lv_obj_get_coords(btnm, &btnm_area); + lv_area_copy(&btn_area, &ext->button_areas[ext->btn_id_pr]); btn_area.x1 += btnm_area.x1; btn_area.y1 += btnm_area.y1; btn_area.x2 += btnm_area.x1; btn_area.y2 += btnm_area.y1; lv_inv_area(&btn_area); - ext->btn_id_tgl = ext->btn_id_pr; - } + if(ext->toggle != 0) { + /*Invalidate to old toggled area*/; + lv_area_copy(&btn_area, &ext->button_areas[ext->btn_id_tgl]); + btn_area.x1 += btnm_area.x1; + btn_area.y1 += btnm_area.y1; + btn_area.x2 += btnm_area.x1; + btn_area.y2 += btnm_area.y1; + lv_inv_area(&btn_area); + ext->btn_id_tgl = ext->btn_id_pr; + } - -#if USE_LV_GROUP - /*Leave the clicked button as pressed if this the focused object in a group*/ - lv_group_t * g = lv_obj_get_group(btnm); - if(lv_group_get_focused(g) != btnm) { + #if USE_LV_GROUP + /*Leave the clicked button as pressed if this the focused object in a group*/ + lv_group_t * g = lv_obj_get_group(btnm); + if(lv_group_get_focused(g) != btnm) { + ext->btn_id_pr = LV_BTNM_PR_NONE; + } + #else ext->btn_id_pr = LV_BTNM_PR_NONE; + #endif + } -#else - ext->btn_id_pr = LV_BTNM_PR_NONE; -#endif } } else if(sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_DEFOCUS) { ext->btn_id_pr = LV_BTNM_PR_NONE;