Hooks ‹ Chocolat API

Hooks.addMenuItem(path, shortcut, callback)

Add a menu item at the given path.

  • path String – the path of the new menu item.
  • shortcut String – keyboard shortcut, e.g. `ctrl-alt-cmd-b`.
  • callback Function – a callback to be executed when the menu item is selected.

Hooks.addKeyboardShortcut(shortcut, callback)

Add a keyboard shortcut.

  • shortcut String – the keyboard shortcut, e.g. `ctrl-alt-cmd-b`
  • callback Function – the callback function to execute.

Hooks.addStatusItem(name, valueFunction, selector)

Add an item in the bottom status bar.

  • name String – the name of the item to add.
  • valueFunction Function – a function that will return the value to display in the status bar.
  • selector String – a scope selector e.g. `source.objc`

Hooks.setShortcutForMenuItem(path, shortcut)

Remap a menu item to a new keyboard shortcut.

  • path String – the path of the menu item to change.
  • shortcut String – keyboard shortcut, e.g. `ctrl-alt-cmd-b`.

Example

UI.setShortcutForMenuItem("Go/Go To File...", "cmd-t");