MenuManager

Description

Provides a registry for menu items that you'd like to appear in the application menu.

An instance of this class is always available as the atom.menu global.

Here is an example from the tree-view:

[
  {
    'label': 'View'
    'submenu': [
      { 'label': 'Toggle Tree View', 'command': 'tree-view:toggle' }
    ]
  }
  {
    'label': 'Packages'
    'submenu': [
      'label': 'Tree View'
      'submenu': [
        { 'label': 'Focus', 'command': 'tree-view:toggle-focus' }
        { 'label': 'Toggle', 'command': 'tree-view:toggle' }
        { 'label': 'Reveal Active File', 'command': 'tree-view:reveal-active-file' }
        { 'label': 'Toggle Tree Side', 'command': 'tree-view:toggle-side' }
      ]
    ]
  }
]

Use in your package's menu .cson file requires that you place your menu structure under a menu key.

'menu': [
  {
    'label': 'View'
    'submenu': [
      { 'label': 'Toggle Tree View', 'command': 'tree-view:toggle' }
    ]
  }
]

See MenuManager::add for more info about adding menu's directly.

API documentation

All methods

::add(items)

Adds the given items to the application menu.

Argument Description
items

An Array of menu item Objects containing the keys:

label

The String menu label.

submenu

An optional Array of sub menu items.

command

An optional String command to trigger when the item is clicked.

id

(internal) A String containing the menu item's id. Returns a Disposable on which .dispose() can be called to remove the added menu items.

::update()

Refreshes the currently visible menu.