0.1.1 • Published 9 years ago

nw-appmenu v0.1.1

Weekly downloads
10
License
-
Repository
github
Last release
9 years ago

nw-appmenu

Helper to work with application menu in nwjs (node-webkit)

Install:

npm install nw-appmenu

Example:

var AppMenu = require('nw-appmenu');

// we will add Zoom In, Zoom Out, Inspector, Reload, Help items to window menu
var menu = {
  'Window': {
    'separator': 'separator',
    'Zoom in': {
      click: function () {
        gui.Window.get().zoomLevel += 0.5;
      },
      key: '+'
    },
    'Zoom out': {
      click: function () {
        gui.Window.get().zoomLevel -= 0.5;
      },
      key: '-'
    },
    'Zoom to noraml': {
      click: function () {
        gui.Window.get().zoomLevel = 0;
      },
      key: '0'
    },
    'separator2': 'separator',
    Inspector: {
      click: function () {
        var win = gui.Window.get();
        if (win.isDevToolsOpen()) {
          win.closeDevTools();
        } else {
          win.showDevTools();
        }
      },
      key: 'i'
    },
    Reload: {
      click: function () {
        gui.Window.get().reloadDev();
      },
      key: 'r'
    },
    Help: function() {
      window.alert("help window");
    }
  }
};

AppMenu.createAndExtend(menu);

screen shot 2015-04-29 at 1 55 56

I extrac this code from Postbird, please see example_app folder for more features and options.