Rebuild PopUp-menu options when the user clicks to open
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I've tried searching through most of the popup menu-related questions and didn't find anything similar. Essentially, I'd like to be able to dynamically populate a popup menu every time the user clicks it.
My current approach involves setting the menu's Enable property to ' inactive' so that it appears enabled but still calls my ButtonDownFcn callback. The user clicks the inactive menu, my callback reloads/adds options, and then sets the menu's Enable property to ' on'.
The problem is that the user has to click the menu twice to actually get it to open due to changing it's Enable property.
Is there any way to force the menu to open within my ButtonDownFcn callback so that it behaves normally for the user?
4 comentarios
Jan
el 14 de Ag. de 2018
I do not understand, what "when the user clicks on it, just before the menu actually opens" exactly means. But I assume, you find the wanted callback in the Java level: https://undocumentedmatlab.com/blog/uicontrol-callbacks
Respuestas (1)
Adam Danz
el 13 de Ag. de 2018
Editada: Adam Danz
el 13 de Ag. de 2018
Here are some ideas for solution
1) Create a small "refresh" button near the menu; the user can click it to refresh the list of files.
2) Create a timer function that continually checks the directory in the background every 'x' seconds and updates the menu whenever there is an update in the directory.
3) Any time the user interacts with the popup menu, it checks for changes in the directory and updates the list (after the user already clicked - which is weird).
If any of those solutions are viable and you need help getting started, I'd be glad to help.
0 comentarios
Ver también
Categorías
Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!