wxMenus and popup menus

BlitzMax Forums/Brucey's Modules/wxMenus and popup menus

Pete Rigz(Posted 2013) [#1]
I just want to double check before I have to create some new menus...

Previously I could re-use a menu, for example my edit menu that's on the menu bar I could make it a popup menu when you right click the treeview. Now that's throwing an assert: menus attached to a menu bar can't have invoking window.

Fair enough, but is there a sneaky way I can detach it temporarily for the popup and then re-attach, or should I just create the same menus again and use them instead?

Thanks :)


Brucey(Posted 2013) [#2]
MenuBar has a Remove:wxMenu(index) method, which will detach the menu at the given index from the menubar. It also has an equivalent Insert(index, menu, title) method for adding one back to a given position.

That might be the easiest way to go about it for now.

I see in the wxMenu header, and on the documentation page ( http://docs.wxwidgets.org/trunk/classwx_menu.html ) there are some new, (relatively) undocumented methods which are listed as "implementation helpers", called Detach(), Attach(), GetParent() and SetParent() respectively. There's also an IsAttached() method in the header that isn't documented, which returns true if the menu is attached to a menubar (from the source : "is the menu attached to a menu bar (or is it a popup one)?")

Dunno if I can added the Attach(menubar) code to wxMenu because it will likely incur a circular import. But I don't think we need it, since you can call Insert() or Append() in wxMenuBar already.
Detach() may be useful, and doesn't reference the menubar, so we should be good to go with adding that.

HTH


Pete Rigz(Posted 2013) [#3]
Thanks Brucey, I made a separate menu for one pop up as it wasn't too much trouble anyway, but still have another to sort out so it would be cool to test out the detach method. I wonder if it will actually make it disappear from the menu bar while the popup is there though...


UNZ(Posted 2013) [#4]
Hi,
I'm just using this thread for a new wxMenu topic:

Bitmaps applied manually to a menu item don't appear on linux.
sample:


this is not a big thing but it would look nicer with icons.