Focus not updating automatically when switching screens
Description
What MCU/Processor/Board and compiler are you using?
PC simulator
What LVGL version are you using?
v9.2
What do you want to achieve?
I want to switch from one screen to another using lv_screen_load_anim()
, and I expect the focus to move automatically to the new screen while being removed from the old one.
What have you tried so far?
I noticed that when changing screens with lv_screen_load_anim()
, the previous screen does not lose focus, and the new screen does not gain focus automatically. I had to explicitly call lv_group_focus_obj()
to set focus on a widget in the new screen.
Is this the intended behavior, or am I missing something? Should LVGL handle this automatically when switching screens?
Code to reproduce
Here is a minimal example:
void _ui_screen_change(lv_obj_t **target, lv_screen_load_anim_t fademode, int spd, int delay,
void (*target_init)(void))
{
if (*target == NULL)
target_init();
lv_scr_load_anim(*target, fademode, spd, delay, false);
if (ui_Screen_1 == *g->obj_focus)
LOG("ui_Screen_1");
if (ui_Screen_2 == *g->obj_focus)
LOG("ui_Screen_2");
if (ui_Screen_3 == *g->obj_focus)
LOG("ui_Screen_3");
}
I expected obj_focus to point to a widget on the newly loaded screen, but it seems to retain focus from the previous screen.
Should I manually manage focus when switching screens, or is there a built-in way to handle this automatically?