MenuItem
Extends: MenuItemBase
A menu item that can be clicked to perform an action.
import { MenuItem } from '@mobrowser/api';
Example
import { app, Menu, MenuItem } from '@mobrowser/api';
const menu = new Menu({
items: [
new MenuItem({
id: 'save',
label: 'Save',
shortcut: 'CommandOrControl+S',
action: (item: MenuItem) => { }
})
]
})
app.setMenu(menu)
Properties
id
readonly id: string;
The ID of the menu item.
label
readonly label?: string;
The label of the menu item.
enabled
readonly enabled?: boolean;
Whether the menu item is enabled.
shortcut
readonly shortcut?: Shortcut;
The shortcut of the menu item.
action
readonly action?: (item: MenuItem) => void;
The action to perform when the menu item is clicked.
Methods
constructor()
constructor(options: MenuItemBaseOptions<MenuItem>): void;
Creates a new menu item.
| Parameter | Type | Description |
|---|---|---|
options | MenuItemBaseOptions<MenuItem> | The options for constructing the menu item. |
setLabel()
setLabel(label: string): void;
Sets the label of the menu item.
| Parameter | Type | Description |
|---|---|---|
label | string | The label of the menu item. |
setEnabled()
setEnabled(enabled: boolean): void;
Sets whether the menu item is enabled.
| Parameter | Type | Description |
|---|---|---|
enabled | boolean | Whether the menu item is enabled. |
setShortcut()
setShortcut(shortcut: Shortcut): void;
Sets the shortcut of the menu item.
| Parameter | Type | Description |
|---|---|---|
shortcut | Shortcut | The shortcut of the menu item. |