[MAXGUI] Sub-menu example?
BlitzMax Forums/BlitzMax Beginners Area/[MAXGUI] Sub-menu example?
| ||
Hello! Can someone give me an example how one can create sub-menus such as in the BMX IDE. ![]() Thanks. |
| ||
a submenu is simply a menu (CreateMenu) with another menu as parent.. |
| ||
The blitz docs are really not of much help. I understand how a submenu functions in theory. But I can't get bmx to create one. Here's the wonderfull example from the docs: Strict Local window:TGadget Local filemenu:TGadget Local editmenu:TGadget Local helpmenu:TGadget Const MENU_NEW=101 Const MENU_OPEN=102 Const MENU_SAVE=103 Const MENU_CLOSE=104 Const MENU_EXIT=105 Const MENU_CUT=106 Const MENU_COPY=107 Const MENU_PASTE=108 Const MENU_ABOUT=109 window=CreateWindow("My Window",40,40,320,240) filemenu=CreateMenu("&File",0,WindowMenu(window)) CreateMenu"&New",MENU_NEW,filemenu,KEY_N,MODIFIER_COMMAND CreateMenu"&Open",MENU_OPEN,filemenu,KEY_O,MODIFIER_COMMAND CreateMenu"&Close",MENU_CLOSE,filemenu,KEY_W,MODIFIER_COMMAND CreateMenu"",0,filemenu CreateMenu"&Save",MENU_SAVE,filemenu,KEY_S,MODIFIER_COMMAND CreateMenu"",0,filemenu CreateMenu"E&xit",MENU_EXIT,filemenu,KEY_F4,MODIFIER_COMMAND editmenu=CreateMenu("&Edit",0,WindowMenu(window)) CreateMenu "Cu&t",MENU_CUT,editmenu,KEY_X,MODIFIER_COMMAND CreateMenu "&Copy",MENU_COPY,editmenu,KEY_C,MODIFIER_COMMAND CreateMenu "&Paste",MENU_PASTE,editmenu,KEY_V,MODIFIER_COMMAND helpmenu=CreateMenu("&Help",0,WindowMenu(window)) CreateMenu "&About",MENU_ABOUT,helpmenu UpdateWindowMenu window While True WaitEvent Select EventID() Case EVENT_WINDOWCLOSE End Case EVENT_MENUACTION Select EventData() Case MENU_EXIT End Case MENU_ABOUT Notify "Incrediabler~n(C)2005 Incredible Software" End Select End Select Wend Could u add a submenu to any element? I don't get it... :/ |
| ||
the example just works.. what's strange about it? this: filemenu=CreateMenu("&File",0,WindowMenu(window)) creates the filemenu, not the whole menu, just the word 'File' on the menubar of a window. Therefor the parent is the WindowMenu(window). same with editmenu=CreateMenu("&Edit",0,WindowMenu(window)) and helpmenu=CreateMenu("&Help",0,WindowMenu(window)) and then you simply add the filemenu to the File 'word' hence: CreateMenu"&New",MENU_NEW,filemenu,KEY_N,MODIFIER_COMMAND likewise for the rest.. |
| ||
I understand how I can create a basic file menu. But NOT how these sub-menus work! By sub-menu I mean a menu entry with an arrow, so that the user has 3 more options to choose from. ![]() |
| ||
a submenu is a menu with a menuitem as parent.. what's so hard on that? So, have a filemenu have some menuitems like load, save, quit etc. make sure the one which should have a submenu has a handle.. make a submenu, just another menu, and let the parent be the handle.. ' createmenu.bmx Strict Local window:TGadget Local filemenu:TGadget Local editmenu:TGadget Local helpmenu:TGadget Const MENU_NEW=101 Const MENU_OPEN=102 Const MENU_SAVE=103 Const MENU_CLOSE=104 Const MENU_EXIT=105 Const MENU_CUT=106 Const MENU_COPY=107 Const MENU_PASTE=108 Const MENU_ABOUT=109 window=CreateWindow("My Window",40,40,320,240) filemenu=CreateMenu("&File",0,WindowMenu(window)) CreateMenu"&New",MENU_NEW,filemenu,KEY_N,MODIFIER_COMMAND CreateMenu"&Open",MENU_OPEN,filemenu,KEY_O,MODIFIER_COMMAND CreateMenu"&Close",MENU_CLOSE,filemenu,KEY_W,MODIFIER_COMMAND CreateMenu"",0,filemenu Local somesubmenu:TGadget=CreateMenu("&Save",MENU_SAVE,filemenu,KEY_S,MODIFIER_COMMAND) CreateMenu"",0,filemenu CreateMenu"E&xit",MENU_EXIT,filemenu,KEY_F4,MODIFIER_COMMAND editmenu=CreateMenu("&Edit",0,somesubmenu) CreateMenu "Cu&t",MENU_CUT,editmenu,KEY_X,MODIFIER_COMMAND CreateMenu "&Copy",MENU_COPY,editmenu,KEY_C,MODIFIER_COMMAND CreateMenu "&Paste",MENU_PASTE,editmenu,KEY_V,MODIFIER_COMMAND helpmenu=CreateMenu("&Help",0,WindowMenu(window)) CreateMenu "&About",MENU_ABOUT,helpmenu UpdateWindowMenu window While True WaitEvent Select EventID() Case EVENT_WINDOWCLOSE End Case EVENT_MENUACTION Select EventData() Case MENU_EXIT End Case MENU_ABOUT Notify "Incrediabler~n(C)2005 Incredible Software" End Select End Select Wend |
| ||
Thanks again CS. I'm really too much newbie to handle the bmx docs. With B3D and BP all seemed a lot more easier in terms of command documentation and handling to me. |
| ||
BP's manual was very good indeed, bmax manual is very minimalistic and sometimes even incomplete, functionality-wise. Even worse: some examples are written for non-strict mode so thosee examples demonstrate lazy code-style. Tho the whole MaxGUI thing is largely like B+, the createmenu thing is also in the B+ manual.. |
| ||
Another question: How do I get a "selected arrow" next to a menu entry? (like in "- build Gui app") CheckMenu? I have 2 submenu options and one shall be selected when the user clicks it. |