lvgl: stuck when using the encoder to focus to the hidden msgbox

Perform all steps below and tick them with [x]

  • Read the FAQ
  • Check the related part of the Documentation
  • Update lvgl to the latest version
  • Reproduce the issue in a Simulator

Describe the bug

I have an msgbox in my screen and an encoder registered in LVGL; When I hide the Button matrix in it(or hide the whole msgbox and before hide the msgbox, the encoder already focus on it), the encoder will still focus on the Button matrix, and once I press the encoder’s key and rotate the encoder, the program will stop in the while loop because it can’t find the next element to focus on.

To Reproduce

// hide the btnmatrix
lv_obj_t * msgbut = lv_msgbox_get_btns(msgbox_1);
lv_btnmatrix_set_btn_ctrl_all(msgbut, LV_BTNMATRIX_CTRL_HIDDEN);
// or hide the msgbox by software but the btnmatrix in msgbox already been focused
lv_obj_add_flag(msgbox_1, LV_OBJ_FLAG_HIDDEN);

Expected behavior

The program actively jumps out of the hidden button matrix.

Screenshots or video

snap

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 41 (8 by maintainers)

Most upvoted comments

Hi @kisvegabor ,

My sincere apologies I seemed to have missed your reply!

It sounds really complicated. What if we leave it to the user instead of supporting this edge case in LVGL? It should be doable to call an lv_group_focus_obj() when needed.

I agree it is a conundrum to solve, my only concern is I think it is possible to cause a crash. I will see if I can create a test case to demonstrate.

Here I think the solution would be to allow “trapping” focus on any widget. If a parent widget has focus trap, only it’s children can be focused. What do you think?

I think this is a good solution, is it something you want to implement or if you specify how you want it to be implemented I may be able to take a look. Maybe it could be another flag? LV_OBJ_FLAG_FOCUS_TRAPPED?

Let me know what you think.

Kind Regards,

Pete

Hi @fivekernels ,

Thank you for taking time to quantify this, I think the issues have been multiple and this one has gotten lost in the noise… I can see now it’s related to the lv_btnmatrix_set_btn_ctrl() call specifically, my fix addresses setting the visibility flag at an object level… I will need to explore this further to find what is happening in this scenario…

I will let you know here, when I find a solution to the issue.

Kind Regards,

Pete