1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-21 06:53:01 +08:00

lv_btnm: ignore clicks on inactive buttons

This commit is contained in:
Gabor Kiss-Vamosi 2018-10-12 09:09:10 +02:00
parent b6b77f4b45
commit 0ee104d155

View File

@ -547,12 +547,9 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
} }
} else if(sign == LV_SIGNAL_RELEASED) { } else if(sign == LV_SIGNAL_RELEASED) {
if(ext->btn_id_pr != LV_BTNM_PR_NONE) { if(ext->btn_id_pr != LV_BTNM_PR_NONE) {
if(ext->action) {
uint16_t txt_i = get_button_text(btnm, ext->btn_id_pr); 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) { 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*/
ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i])); if(ext->action)ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i]));
}
}
/*Invalidate to old pressed area*/; /*Invalidate to old pressed area*/;
lv_obj_get_coords(btnm, &btnm_area); lv_obj_get_coords(btnm, &btnm_area);
@ -571,12 +568,10 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
btn_area.x2 += btnm_area.x1; btn_area.x2 += btnm_area.x1;
btn_area.y2 += btnm_area.y1; btn_area.y2 += btnm_area.y1;
lv_inv_area(&btn_area); lv_inv_area(&btn_area);
ext->btn_id_tgl = ext->btn_id_pr; ext->btn_id_tgl = ext->btn_id_pr;
} }
#if USE_LV_GROUP #if USE_LV_GROUP
/*Leave the clicked button as pressed if this the focused object in a group*/ /*Leave the clicked button as pressed if this the focused object in a group*/
lv_group_t * g = lv_obj_get_group(btnm); lv_group_t * g = lv_obj_get_group(btnm);
@ -586,6 +581,8 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
#else #else
ext->btn_id_pr = LV_BTNM_PR_NONE; ext->btn_id_pr = LV_BTNM_PR_NONE;
#endif #endif
}
} }
} else if(sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_DEFOCUS) { } else if(sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_DEFOCUS) {
ext->btn_id_pr = LV_BTNM_PR_NONE; ext->btn_id_pr = LV_BTNM_PR_NONE;