lv_btnmatrix: don't crash when pointer events aren't on a button
This commit is contained in:
@@ -799,12 +799,15 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa
|
|||||||
/*Search the pressed area*/
|
/*Search the pressed area*/
|
||||||
lv_indev_get_point(param, &p);
|
lv_indev_get_point(param, &p);
|
||||||
btn_pr = get_button_from_point(btnm, &p);
|
btn_pr = get_button_from_point(btnm, &p);
|
||||||
if(button_is_inactive(ext->ctrl_bits[btn_pr]) == false &&
|
/*Handle the case where there is no button there*/
|
||||||
button_is_hidden(ext->ctrl_bits[btn_pr]) == false) {
|
if(btn_pr != LV_BTNMATRIX_BTN_NONE) {
|
||||||
invalidate_button_area(btnm, ext->btn_id_pr) /*Invalidate the old area*/;
|
if(button_is_inactive(ext->ctrl_bits[btn_pr]) == false &&
|
||||||
ext->btn_id_pr = btn_pr;
|
button_is_hidden(ext->ctrl_bits[btn_pr]) == false) {
|
||||||
ext->btn_id_act = btn_pr;
|
invalidate_button_area(btnm, ext->btn_id_pr) /*Invalidate the old area*/;
|
||||||
invalidate_button_area(btnm, ext->btn_id_pr); /*Invalidate the new area*/
|
ext->btn_id_pr = btn_pr;
|
||||||
|
ext->btn_id_act = btn_pr;
|
||||||
|
invalidate_button_area(btnm, ext->btn_id_pr); /*Invalidate the new area*/
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if LV_USE_GROUP
|
#if LV_USE_GROUP
|
||||||
@@ -827,15 +830,16 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa
|
|||||||
/*Search the pressed area*/
|
/*Search the pressed area*/
|
||||||
lv_indev_get_point(param, &p);
|
lv_indev_get_point(param, &p);
|
||||||
btn_pr = get_button_from_point(btnm, &p);
|
btn_pr = get_button_from_point(btnm, &p);
|
||||||
/*Invalidate to old and the new areas*/;
|
/*Invalidate to old and the new areas*/
|
||||||
if(btn_pr != ext->btn_id_pr &&
|
if(btn_pr != ext->btn_id_pr) {
|
||||||
button_is_inactive(ext->ctrl_bits[btn_pr]) == false &&
|
|
||||||
button_is_hidden(ext->ctrl_bits[btn_pr]) == false) {
|
|
||||||
lv_indev_reset_long_press(param); /*Start the log press time again on the new button*/
|
|
||||||
if(ext->btn_id_pr != LV_BTNMATRIX_BTN_NONE) {
|
if(ext->btn_id_pr != LV_BTNMATRIX_BTN_NONE) {
|
||||||
invalidate_button_area(btnm, ext->btn_id_pr);
|
invalidate_button_area(btnm, ext->btn_id_pr);
|
||||||
}
|
}
|
||||||
if(btn_pr != LV_BTNMATRIX_BTN_NONE) {
|
lv_indev_reset_long_press(param); /*Start the log press time again on the new button*/
|
||||||
|
if(btn_pr != LV_BTNMATRIX_BTN_NONE &&
|
||||||
|
button_is_inactive(ext->ctrl_bits[btn_pr]) == false &&
|
||||||
|
button_is_hidden(ext->ctrl_bits[btn_pr]) == false) {
|
||||||
|
/* Send VALUE_CHANGED for the newly pressed button */
|
||||||
uint32_t b = ext->btn_id_act;
|
uint32_t b = ext->btn_id_act;
|
||||||
res = lv_event_send(btnm, LV_EVENT_VALUE_CHANGED, &b);
|
res = lv_event_send(btnm, LV_EVENT_VALUE_CHANGED, &b);
|
||||||
if(res == LV_RES_OK) {
|
if(res == LV_RES_OK) {
|
||||||
|
|||||||
Reference in New Issue
Block a user