Tear off menu

BlitzMax Forums/MaxGUI Module/Tear off menu

LAB[au](Posted 2007) [#1]
Hello,

I would like to add tear off menu, a floating windows with a menu open in it, like instead of clicking on file on the main window menu, you can select the first element of the menu which is called "tearoff" and then the menu appears opened in a floating tool window.

I have been looking unsuccessfully at maxgui.bmx in hope to find some code knowing that what I want to achieve is quite similar to a popup menu except that it has a frame (with a close button like a tool window) that it is created not at mouse position and that it stays open.

Any help appreciated.


SpaceAce(Posted 2007) [#2]
Hm, is there some reason you can't do the following ...

FloatingMenu:TGadget = CreateWindow("Menu", 20, 20, 100, 100)


... then just add gadgets to the new window?

SpaceAce


LAB[au](Posted 2007) [#3]
Well yes you can do that but it won't be like a popupmenu and won't behave like a menu, I would have to add buttons (not exactly like a menu item) etcetera.

It's definitively possible since popupmenus are almost that (window without frame that opens at mouse position). In this case it would be a window with frame (tool window) with a "unfolded" menu in it.

If you have Maya and you click on the first separator in a menu, you tear it off.

look at these 2 screenshots showing the process:




SpaceAce(Posted 2007) [#4]
Yes, I know what tearoff menus are. I'm not sure I understand what you mean by saying using the new window won't act like a menu. The gadgets will behave however you tell them to. I don't think there's any reason you couldn't create and arrange gadgets to look just like a regular menu.

Another possibility (which I have never tried and have no idea whether or not it will work properly) is to create a MaxGUI panel object and make it the parent of your menu. Then, position and update the panel however you please in your code.

SpaceAce


LAB[au](Posted 2007) [#5]
Thanks for the suggestion, I tried with panel parenting a menu to it, but the menu doesn't show up.

That leaves only the possibility to fake a menu with gadgets.


allos(Posted 2007) [#6]
in the code archives there is an interesting use of panels to build foldable menus; working on it you can load them and discard them 'on demand' (in the original implementation this is static stuff)
you can give them a try, also if this is not what people call tearoff menu
look at http://www.blitzbasic.com/codearcs/codearcs.php?code=1875

allos


LAB[au](Posted 2007) [#7]
Nice I didn't noticed this contribution, thanks! This is not tear off menu, it's foldable panels I would say.