I’m trying to make a popupmenu for my plugin’s preset system. I’ve been trying to mimic fabfilter’s popupmenu system which allows you to browse the file system via popupmenus/submenus. From some testing it seems fabfilter (or similar) tries to load the entire folder structure from the desired root preset folder and then mirror this with popupmenus and submenus. However, it seems to stops loading items if a certain amount of folders/items is met. For example, you get lots of blank submenus if you set the root preset folder to any folder with too much content e.g. C:.
But, I’m unsure what criteria it uses to decide which folders/presets to include, and I was thinking that a more lazy way of loading folders could be simpler and prevent the issue of loading blank submenus and not explaining why.
For example, one could populate a submenu’s items at the point that they are actually shown and then empty them when they disappear. Or to prevent running so many file system operations, one could keep a queue of submenus such that whenever a new submenu (one not in the queue) is shown, you add it to the front of the queue and remove menus from the back of the queue and empty them until all qeued menus are currently being shown or the queue contains n items. The only problem with this is that I cannot find an easy way to hook into when a popupmenu is actually about to be shown or about to disappear. I also thought perhaps I could achieve a similar result by creating the actual submenu when it’s about to be shown and removing it when no longer needed. But looks like you cannot remove submenus and I cannot find a way of hooking into when a submenu would need to be constructed. Does anyone know if this is possible?
