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,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) { } 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(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(txt_i != LV_BTNM_PR_NONE && button_is_inactive(ext->map_p[txt_i]) == false) { if(ext->action)ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i]));
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);
lv_area_copy(&btn_area, &ext->button_areas[ext->btn_id_pr]); 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]);
btn_area.x1 += btnm_area.x1; btn_area.x1 += btnm_area.x1;
btn_area.y1 += btnm_area.y1; btn_area.y1 += btnm_area.y1;
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; 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
#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); if(lv_group_get_focused(g) != 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; 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) { } 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;