thank you for all the great support so far. However, I have another question: how to handle the ESC key programmatically?
I have read the documentation and from Button Events - Vobot Mini Dock it should behave like every other key. However, when looking at the logs, the ESC key is never processed by the event handler function - instead the app is terminated instantly (I can see the on_stop()-Method being called).
In your examples, you added the line
CAN_BE_AUTO_SWITCHED = True
If I set this to False, then the code for the ESC key is being called, but the app is still terminated (actually, it should not be related, since auto switching is a different feature, but anyway).
In JavaScript I know the concept that an event is bubbling up through all the instances, which are related. I saw in the LVGL docu, that, LVGL has a similar concept of Event Bubbling (Events — LVGL documentation). Is this the main reason (and if so: how can I stop event bubbling)?
Long story short: Please help me intercept the ESC key.
Thank you very much for your support. Here are the responses to your questions:
Press the ESC button and the application will terminate immediately
1 The Dock Hub system provides an App exit mechanism. When the ESC button is pressed, it can automatically exit the App to the menu page without you having to write additional code
2 For the App exit mechanism, you can refer to app_mgr.enter_root_page() and app_mgr.leave_root_page() in Application manager in the Dock Hub Development Guide
1.3 The App exit mechanism is turned on by default every time the device is turned on. If you want to turn off this function, you can call app_mgr.leave_root_page()
1.4 Note:
After calling app_mgr.leave_root_page(), the App needs to call app_mgr.enter_root_page() again to turn the function back on
From the button event - Vobot Mini Dock, it should work like all other keys. However, when checking the log, the event handler function has never processed the ESC key
2.1 The reasons for this situation are roughly as follows:
Before the event handler function is processed, the App has exited; you can try again after turning off the App exit mechanism to see if it appears again
The object currently focused by lvgl is not the control corresponding to the event handler function; you can check the object currently focused by lvgl to determine whether it is the target control
lvgl will recognize some key events internally. After internal recognition, lvgl will not call the custom event handler function; you can try to call send_event to simulate different event triggers to see if the event handler function can be captured normally
2.2 If none of the above situations are true, can you provide us with a simple source code of the App program that can reproduce the problem you encountered?
We will troubleshoot and locate the problem based on the program source code you provided
Explanation of CAN_BE_AUTO_SWITCHED
3.1 CAN_BE_AUTO_SWITCHED is used to notify the Dock Hub system that the App supports the automatic rotation function
3.2 CAN_BE_AUTO_SWITCHED is theoretically irrelevant to the problem you mentioned, and it does not affect the event handler function
If you have any questions about the product, please feel free to contact us.