Skip to content

Commit

Permalink
fix(btnmamatrix) fix focus event handling
Browse files Browse the repository at this point in the history
  • Loading branch information
kisvegabor committed Jun 2, 2021
1 parent 57e211c commit 3b58ef1
Showing 3 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/core/lv_group.c
Original file line number Diff line number Diff line change
@@ -206,7 +206,7 @@ void lv_group_focus_obj(lv_obj_t * obj)

if(g->frozen != 0) return;

// if(g->obj_focus != NULL && obj == *g->obj_focus) return;
if(g->obj_focus != NULL && obj == *g->obj_focus) return;

/*On defocus edit mode must be leaved*/
lv_group_set_editing(g, false);
1 change: 1 addition & 0 deletions src/core/lv_obj.c
Original file line number Diff line number Diff line change
@@ -763,6 +763,7 @@ static void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state)
lv_obj_refresh_style(obj, LV_PART_ANY, LV_STYLE_PROP_ANY);
}
else if(cmp_res == _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD) {
lv_obj_invalidate(obj);
lv_obj_refresh_ext_draw_size(obj);
}
}
21 changes: 12 additions & 9 deletions src/widgets/lv_btnmatrix.c
Original file line number Diff line number Diff line change
@@ -517,17 +517,20 @@ static void lv_btnmatrix_event(const lv_obj_class_t * class_p, lv_event_t * e)
}

bool editing = lv_group_get_editing(lv_obj_get_group(obj));
if(indev_type == LV_INDEV_TYPE_KEYPAD|| (indev_type == LV_INDEV_TYPE_ENCODER&& editing)) {
uint32_t b = 0;
if(btnm->one_check) {
while(button_is_hidden(btnm->ctrl_bits[b]) || button_is_inactive(btnm->ctrl_bits[b]) || button_is_checked(btnm->ctrl_bits[b]) == false) b++;
/*Focus the first button if there is not selected button*/
if(btnm->btn_id_sel == LV_BTNMATRIX_BTN_NONE) {
if (indev_type == LV_INDEV_TYPE_KEYPAD || (indev_type == LV_INDEV_TYPE_ENCODER && editing)) {
uint32_t b = 0;
if(btnm->one_check) {
while(button_is_hidden(btnm->ctrl_bits[b]) || button_is_inactive(btnm->ctrl_bits[b]) || button_is_checked(btnm->ctrl_bits[b]) == false) b++;
} else {
while(button_is_hidden(btnm->ctrl_bits[b]) || button_is_inactive(btnm->ctrl_bits[b])) b++;
}

btnm->btn_id_sel = b;
} else {
while(button_is_hidden(btnm->ctrl_bits[b]) || button_is_inactive(btnm->ctrl_bits[b])) b++;
btnm->btn_id_sel = LV_BTNMATRIX_BTN_NONE;
}

btnm->btn_id_sel = b;
} else {
btnm->btn_id_sel = LV_BTNMATRIX_BTN_NONE;
}
}
else if(code == LV_EVENT_DEFOCUSED || code == LV_EVENT_LEAVE) {

0 comments on commit 3b58ef1

Please sign in to comment.