MenuBar

MenuBar UI component is used to create a menu bar at the top of the application. It extends UIComponent class.

Menu bar can be added to Window in two ways, by setting the MenuBar as the Window's main menu bar using window.menuBar(menuBar) method, or adding the MenuBar object as any other UI component using menuBar.addTo(window) or window.addChild(menuBar).

Using window.menuBar(menuBar) automatically positions and resizes the menu bar to Window's width and in MacOS it uses it as the main menu bar shows at the top menu bar of the operating system.

Adding the menu bar as a regular UI component to Window will keep the menu inside the Window and you will have to resize it by setting the desired width (and optionally height).

Only Menu objects can be added to MenuBar.

Constructor

Constructor of MenuBar UI component.

Parameters:
NameTypeAttributesDescription
textstring<optional>

Text displayed in the menu

Classes

MenuBar

Methods

addChild(component, …indexopt) → {this}

Adds a child menu component to this menu bar. Overrides UIComponent.addChild() to validate components being added.

Parameters:
NameTypeAttributesDescription
componentObject

UI Component that can be a child of this component.

indexany<optional>
<repeatable>

Argument to pass index at which to insert the child. By default component is added to the end.

Returns:

Returns an instance of this component.

Type: 
this