Skip to content

Commit 3b58ef1

Browse files
committed
fix(btnmamatrix) fix focus event handling
1 parent 57e211c commit 3b58ef1

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

src/core/lv_group.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ void lv_group_focus_obj(lv_obj_t * obj)
206206

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

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

211211
/*On defocus edit mode must be leaved*/
212212
lv_group_set_editing(g, false);

src/core/lv_obj.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,7 @@ static void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state)
763763
lv_obj_refresh_style(obj, LV_PART_ANY, LV_STYLE_PROP_ANY);
764764
}
765765
else if(cmp_res == _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD) {
766+
lv_obj_invalidate(obj);
766767
lv_obj_refresh_ext_draw_size(obj);
767768
}
768769
}

src/widgets/lv_btnmatrix.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -517,17 +517,20 @@ static void lv_btnmatrix_event(const lv_obj_class_t * class_p, lv_event_t * e)
517517
}
518518

519519
bool editing = lv_group_get_editing(lv_obj_get_group(obj));
520-
if(indev_type == LV_INDEV_TYPE_KEYPAD|| (indev_type == LV_INDEV_TYPE_ENCODER&& editing)) {
521-
uint32_t b = 0;
522-
if(btnm->one_check) {
523-
while(button_is_hidden(btnm->ctrl_bits[b]) || button_is_inactive(btnm->ctrl_bits[b]) || button_is_checked(btnm->ctrl_bits[b]) == false) b++;
520+
/*Focus the first button if there is not selected button*/
521+
if(btnm->btn_id_sel == LV_BTNMATRIX_BTN_NONE) {
522+
if (indev_type == LV_INDEV_TYPE_KEYPAD || (indev_type == LV_INDEV_TYPE_ENCODER && editing)) {
523+
uint32_t b = 0;
524+
if(btnm->one_check) {
525+
while(button_is_hidden(btnm->ctrl_bits[b]) || button_is_inactive(btnm->ctrl_bits[b]) || button_is_checked(btnm->ctrl_bits[b]) == false) b++;
526+
} else {
527+
while(button_is_hidden(btnm->ctrl_bits[b]) || button_is_inactive(btnm->ctrl_bits[b])) b++;
528+
}
529+
530+
btnm->btn_id_sel = b;
524531
} else {
525-
while(button_is_hidden(btnm->ctrl_bits[b]) || button_is_inactive(btnm->ctrl_bits[b])) b++;
532+
btnm->btn_id_sel = LV_BTNMATRIX_BTN_NONE;
526533
}
527-
528-
btnm->btn_id_sel = b;
529-
} else {
530-
btnm->btn_id_sel = LV_BTNMATRIX_BTN_NONE;
531534
}
532535
}
533536
else if(code == LV_EVENT_DEFOCUSED || code == LV_EVENT_LEAVE) {

0 commit comments

Comments
 (0)