Closed vzahradnik closed 1 year ago
Can you take a look and see if the menu manager observer does what you want. It sounds like it should work for you and you can even prevent the menu from showing if you wanted.
In fact, if you could take a look at the below as it does pretty much what you want:
Thanks, I will look into it.
Your solution works great. I'll close this issue. I just have one question. What is the purpose of menuMgr.getCurrentMenu() == item
? When I had this clause in the if statement, my code was not triggered. Once I removed this part, my code started working.
if(item->getId() == menuList.getId() && menuMgr.getCurrentMenu() == item) {
}
The examples sometimes go overboard with things to show all the possible functions that you can use. Checking by ID is fine.
I have a submenu where I dynamically pull the data from the sensors; it's called service screen.
I'd like to define a callback function which is called after user enters the menu. Currently,
SubMenuItem
s don't support callback functions.My workaround is to periodically check whether user is or is not in this menu:
This code works however is not efficient. Instead of executing the code only once (as in the case of callback version), it is called periodically while user stays in the screen.