Menu
Extends: MenuElement
A menu that contains a list of menu items.
import { Menu } from '@mobrowser/api';
Example
import { app, Menu, MenuItem } from '@mobrowser/api';
const menu: Menu = new Menu({
label: 'File',
items: [
new MenuItem({
id: 'open',
label: 'Open',
action: (item: MenuItem) => { console.log('Open') }
})
]
})
app.setMenu(menu)
Properties
label
readonly label?: string;
The label of the menu.
items
readonly items: (MenuElement | MenuItemRole)[];
The items of the menu.
Methods
constructor()
constructor(options: MenuOptions): void;
Creates a new menu.
| Parameter | Type | Description |
|---|---|---|
options | MenuOptions | The options for constructing the menu. |
setLabel()
setLabel(label: string): void;
Sets the label of the menu.
| Parameter | Type | Description |
|---|---|---|
label | string | The label of the menu. |
findItemById()
findItemById(id: string): MenuElement | null;
Finds a menu item by its ID.
| Parameter | Type | Description |
|---|---|---|
id | string | The ID of the menu item to find. |
Return value
The menu item or null if not found.