Gl_MenuBar Object (part of the WidgetManager module)

Description:

The Gl_MenuBar object is a container for drop-down menus. This object can be attached to Gl_Window objects or the desktop (by desktop, I'm referring to the browser canvas here). MenuBars are actually collections of menus and menuItems. These are all separate object types, but since they're always used together, I'll describe them all here.

To use:

<script language="Javascript" src="gamelib_widgets.js"></script>

Here's an example of the creation of a menuBar object with one menu, which itself has a submenu.

var myMenuBar=new Gl_MenuBar(500);
var myMenu=new Gl_Menu('File','#bbbbbb','#ffffff');
    myMenu.addItem('Search','widgetManager.searchWindow()',null,'search.gif');
    myMenu.addItem('Print','widgetManager.doWindowPrint()',null,'print.gif');

var mySubMenu=new Gl_Menu('Options','#bbbbbb','#ffffff');
    mySubMenu.addItem('Option 1','doSomething()',null,null);
    mySubMenu.addItem('Option 2','doSomethingElse()',null,null);

    myMenu.addMenu(mySubMenu);
    myMenu.addItem('Exit','widgetManager.destroyWindow()',null,'fileexit.gif');

myMenuBar.addMenu(myMenu);

So basically, you can only add Menus to MenuBars, but you can add both Menus and MenuItems to Menus. The menuItem object is by far the simplest, it has no methods and is the building block for menus. You don't need to build the MenuItem itself, just call the addItem method on the menu object with the following parameters:

The Gl_Menu objects only have private methods, but can take up to 10 initial parameters, although only the first one is required. If a parameter is ommitted, or set as null, then it is inherited from the parent, or the widgetManager if a top level menu. The default values are set in the setup.html file described in the Widget Module docs.

List of public methods for Gl_MenuBar objects

addMenu
addToDesktop
moveTo

Descriptions of methods for Gl_MenuBar objects

MethodParametersDescription
addMenu Gl_Menu object Adds a top level menu to this menuBar. You can add as many menus to a menubar as you like. The spacing is handled automatically.
addToDesktop none Attaches this menuBar to the desktop.
moveTo Numeric, Numeric Move the menuBar to position x,y. This should only be used with menuBars that have been attached to the desktop (see above).