I’m within my third design of my context menu. Now I have only one menu class for the toplevel/root menu and it’s submenus. Every submenu is a a definition and is stored within it’s own tuple, and each one that contain submenu(s) contains reference(s) to other tuple(s).
The code within draw() of that single generic menu is supposed to iterate through active tuple, fetch each entry, and call layout.operator(), layout.separator(), and layout.menu(), depending of the entry fetched. Here’s my problem. I need to tell layout.menu() to set/pass a variable, which for the purpose of this addon, is a tuple, the active tuple.
My first thought was something along OperatorProperties for operators, and so I figured something like MenuProperties, and although I haven’t tried, the documentation doesn’t contain such a thing so I don’t think that exists. Another option I thought (technically) possible was a parameter (aka the famous almighty ‘userdata’) passed to draw(): draw(self, context, data), appointed with layout.menu(“xol.menu”, data = a_tuple), But the doc doesn’t reveal any such thing either. So the last possibility would be a method of the menu class being called when a submenu was about to open (or draw() receiving that index as parameter), being passed an entry index (identifying the submenu). But I did not see any such thing in the documentation either.
Why is there no “MenuProperties” (OperatorProperties and "MenuProperties btw should be the same thing, with same name) returned by UILayout.menu() ? I think there should. I hope we’re not supposed to programmatically create unique classes for every submenu. That is extremely awkward, and is highly inconsistent with OperatorProperties.
I thought about ‘trickery’, but since any submenu is opened randomly (user’s desire), there is no general programmatic trickery to accomplish this. So I wonder, is there any way to accomplish this with the API (except programmatic creation of unique classes) ? Thank you.