Is there a way to create a menuItem array completely in code or can it only be done from the menubar editor where one needs to at least to create the first element?
I think I have a workaround for that by subclassing MenuItem if that is the case…
The MenuItem Subclass keeps a weakRef to the menubar and in it’s action event writes a reference to itself in the Menubar tag property and returns false. The menuitem selected can then be retrieved in the MenuHandler.
It would be nice if menu handlers just passed in the item selected! I think I put in such a feature request years ago but it never go any traction.
Just to be able to handle a group of related menuItems created entirely in code with a single menuhandler equivalent to (or better than) a menuitem array.
The solution I mentioned above seems to work OK and it’s nice to get the MenuItem instances in the menuhandler. Instead of just getting it’s index you have easy access to it’s tag property.
I have not done much with menus in ages … but now that I got my head back into it, I can think of a number of different solutions… but I think i like this one.
A custom subclass definitely permits this kind of thing as you write it once, implement the event and use the data in the tag property, or any others you add, to determine what to act upon