Spinbox callback, close window with long press after exit editing (using encoder)


I’m facing following problem: I have a submenu in a window which activated by switching the hidden attribute. My project uses an encoder with up/down/enter. The window is closed by long-pressing the enter button, which coincidentally is also releasing the focus of the inner elements of the spinbox.

User flow would be: select spinbox -> press enter -> change value 1 -> press enter -> change value 2 etc. … or -> long press enter to deselect the spinbox and be able to navigate the menu again, or -> long press again to close the menu and return to the previous page.

The problem is, the only events arriving at the spinbox event handler are pressed, short_clicked, clicked, released, focused, defocused, and value changed.

I have been trying to just store the previous event and see if there is a unique event combination if I apply the user flow but there seems to be none. Then I thought, well lets look into the code of spinbox and see where the event is dispatched, maybe I can inject the event I am looking for, but in lv_spinbox.c there is no event being dispatched.

now I am confused and felt like it’s best to ask here, maybe somebody has a pointer for me where to look or an idea how to implement this differently.



It’s because the spinbox changes between navigating and edit mode on long press. However, you get a LV_EVENT_FOCUSED event on navigate/edit change. To decide in which state we are now you can use lv_group_get_editing(lv_obj_get_group(spinbox))