Skip to content

Commit

Permalink
fix(obj) prevent hidden objects keeping focus
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterB authored and PeterB committed Jul 10, 2023
1 parent 1c5d4b0 commit 375b3b5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/core/lv_obj.c
Expand Up @@ -232,12 +232,22 @@ void lv_obj_add_flag(lv_obj_t * obj, lv_obj_flag_t f)

bool was_on_layout = lv_obj_is_layout_positioned(obj);

/* We must invalidate the area occupied by the object before we hide it as calls to invalidate hidden objects are ignored */
if(f & LV_OBJ_FLAG_HIDDEN) lv_obj_invalidate(obj);

obj->flags |= f;

if(f & LV_OBJ_FLAG_HIDDEN) {
lv_obj_invalidate(obj);
if(lv_obj_has_state(obj, LV_STATE_FOCUSED)) {
lv_group_t * group = lv_obj_get_group(obj);
if(group != NULL) {
lv_group_focus_next(group);
lv_obj_t * next_obj = lv_group_get_focused(group);
if(next_obj != NULL) {
lv_obj_invalidate(next_obj);
}
}
}
}

if((was_on_layout != lv_obj_is_layout_positioned(obj)) || (f & (LV_OBJ_FLAG_LAYOUT_1 | LV_OBJ_FLAG_LAYOUT_2))) {
Expand Down

0 comments on commit 375b3b5

Please sign in to comment.