Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
67 lines (50 sloc) 1.707 kb

The menuitems API is a simple way to create Menuitems, which can perform an action when clicked, and display state.

Example

exports.main = function(options) {
  // create menuitem for the File menu,
  // and insert it before the 'Quit' menuitem
  require("menuitems").Menuitem({
    id: "myextprefix-some-mi-id",
    menuid: "menu_FilePopup",
    insertbefore: "menu_FileQuitItem",
    "label": _("label"),
    "accesskey": _("label.ak"),
    image: self.data.url("icon.png"),
    className: 'pizazz',
    disabled: false,
    checked: false,
    onCommand: function() {
      // do something
    }
  });
};

@class

Module exports Menuitem constructor allowing users to create a menuitem.

@constructor Creates a menuitem.

@param options {Object} Options for the menuitem, with the following parameters:

@prop id {String} A id for the menuitem, this should be namespaced.

@prop menuid {String} The id of the parent <menu> node.

@prop label {String} A label for the menuitem.

@prop image {String} A image url for the menuitem.

@prop className {String} A default space delimited list of class names for the menuitem.

@prop disabled {Boolean} When a menuitem is disabled it cannot be used, but is still displayed.

@prop checked {Boolean} Displays a check beside the menuitem.

@prop [onCommand] {Function} A option function that is invoked when the menuitem is executed.

Jump to Line
Something went wrong with that request. Please try again.