Rebuild PopUp-menu options when the user clicks to open
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Jan
2018-8-14
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
回答(1 个)
Adam Danz
2018-8-13
编辑:Adam Danz
2018-8-13
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!