domapi.Menubar
See also: ElmSee 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
});
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 | 0 | The left-offset to apply to the popupmenus when shown. |
| popupY | integer | 0 | 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
| 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 |
| closeItems () |
|---|
Causes all items to close and hide their popupmenus.
| closeLastItem () |
|---|
Causes the last opened item to close.
| hideAllMenus () |
|---|
Hides any visible menus.
| 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. |
| 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. |
| 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 |
| childNodes | type : Collection |
|---|
| isOpened | type : boolean | default value : false |
|---|
This is true if a dropdown menu is showing.
| openedItem | type : HTMLElement |
|---|
A reference to the currently opened item.
