electron-default-menu
Default application menu for Electron apps
Last updated 6 months ago by nonrectangular .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install electron-default-menu 
SYNC missed versions from official npm registry.

electron-default-menu

A simple module that returns a default Electron menu template, similar to the one you'll get if you don't use Menu.setApplicationMenu() at all. You can modify the returned template before creating the application menu.

Based on the sample code supplied in the Electron menu documentation

Like the sample code, it checks the environment, and returns appropriate additional menus for Mac OS X, and sets the role for each menu accordingly.

Must be used from the Electron environment.

Install

Install using npm

npm install --save electron-default-menu

Install using yarn

yarn add electron-default-menu

Example usage:

import { Menu, app, dialog, shell } from 'electron';
import defaultMenu from 'electron-default-menu';

app.on('ready', () => {
  // Get default menu template
  const menu = defaultMenu(app, shell);

  // Add custom menu
  menu.splice(4, 0, {
    label: 'Custom',
    submenu: [
      {
        label: 'Do something',
        click: (item, focusedWindow) => {
          dialog.showMessageBox({message: 'Do something', buttons: ['OK'] });
        }
      }
    ]
  });

  // Set application menu
  Menu.setApplicationMenu(Menu.buildFromTemplate(menu));
});

Current Tags

  • 1.0.2                                ...           latest (6 months ago)

6 Versions

  • 1.0.2                                ...           6 months ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
  • 0.2.0                                ...           5 years ago
  • 0.1.1                                ...           5 years ago
  • 0.1.0                                ...           5 years ago

Copyright 2014 - 2017 © taobao.org |