DomAPI Home
DomAPI

domapi.Menubar

See also: Elm
See also: Component

A standard top-level menubar. Supports infinite cascading submenus and full skinning. Uses Popupmenu components for the child menus.

Each item that is added using Menubar.addItem() to the menubar has a childMenu attribute which is a Popupmenu. They also each have their own Popupmenu.addItem() method for adding the individual items. For example, adding a 'File' top-level menu and then a 'Print' item to it:

menu1 = domapi.Menubar({});
menu1.addItem({text : "File"});
menu1.miFile.addItem({text : "Print", onselected : "window.print()"});
See Popupmenu for more details on dealing with the popupmenus.


Menubar Example: system, aqua

Menubar Constructor

var menubar1 = domapi.Menubar({
  h        : 20,
  w        : null,
  popupX   : 0,
  popupY   : 0,
  doImages : true,
  doShadow : true 
});
Also inherits the construtor arguments of Elm and Component.

Constructor Details
Parameter Type Default Description
h integer 20    
w integer null  Note, if you do not specify a width, the Menubar automatically fill the width of its parent.  
popupX integer The left-offset to apply to the popupmenus when shown. 
popupY integer The top-offset to apply to the popupmenus when shown. 
doImages boolean true  Whether or not to allow for images to be shown in the popupmenus. 
doShadow boolean true  Whether or not to show drop-shadows around the popupmenus. 

Methods unique to domapi.Menubar

Properties unique to domapi.Menubar

Also has the same properties as Elm and Component.

Methods
addItem( arg )

The "arg" parameter fed to this method is an inline Object. See below for accepted parameters.
Any parameters not listed here that you add may also be attached to any returned Object.

This add a top-level menu item and returns a pointer to it. To add sub-menu items to it, use it's addItem() method.

If you give your menuitem a name, you can refer to it by dot-notation, as though it were a property of the menu. For example:

menu.addItem({name:item1});
alert(menu1.item1.visible);
If you do not provide a name, one is created by prefixing "mi" to the text value and camel-casing it. For example:
menu.addItem({text:"My Favorites"});
alert(menu1.miMyFavorites.visible);

Available "arg" Parameters:
Parameter Type Required Default Description
visible boolean   true  Whether or not the item should be hidden. 
text String     The caption to display for the menuitem. 
name String     You can give your menuitems names, that way you can refer to them using dot-notation. 
enabled boolean   true    
back to top
closeItems ()

Causes all items to close and hide their popupmenus.

back to top
closeLastItem ()

Causes the last opened item to close.

back to top
hideAllMenus ()

Hides any visible menus.

back to top
loadFromJson ( json )

Loads the menu from a JSON object. See the test pages for an example of the JSON format used. You can also load the Menubar from a JSON file or url by using [TODO]

Parameters:
Parameter Type Required Default Description
json Object Y   The JSON object. 
back to top
openItem ( item )

Causes a specified menuitem to open and show its popupmenu.

Example:
  menu1.openItem(menu1.miFile);
Parameters:
Parameter Type Required Default Description
item variant Y   Can be either an integer index or item reference. 
back to top
setEnabled ( item, enabled )

Changes the enabled status of a specified item.

Example:
  menu1.setEnabled(menu1.miHelp, false);
Parameters:
Parameter Type Required Default Description
item variant Y   Can be either an index or item reference. 
enabled boolean Y     
back to top
Properties
childNodes type : Collection

 

back to top
isOpened type : boolean default value : false

This is true if a dropdown menu is showing.

back to top
openedItem type : HTMLElement

A reference to the currently opened item.

back to top
DHTML by www.domapi.com