目录

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.

ParameterTypeDescription
optionsMenuOptionsThe options for constructing the menu.

setLabel() 

setLabel(label: string): void;

Sets the label of the menu.

ParameterTypeDescription
labelstringThe label of the menu.

findItemById() 

findItemById(id: string): MenuElement | null;

Finds a menu item by its ID.

ParameterTypeDescription
idstringThe ID of the menu item to find.

Return value 

The menu item or null if not found.