How to use the electron.Menu.buildFromTemplate function in electron

To help you get started, we’ve selected a few electron examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sagargurtu / lector / src / js / main.js View on Github external
});

    // and load the index.html of the app.
    win.loadFile('./src/index.html');

    // Emitted when the window is closed.
    win.on('closed', () => {
        // Dereference the window object, usually you would store windows
        // in an array if your app supports multi windows, this is the time
        // when you should delete the corresponding element.
        win = null;
        aboutWin = null;
    });

    // Create a menu using template
    const menu = Menu.buildFromTemplate(buildMenuTemplate(win));
    // Create about window
    menu.getMenuItemById('about').click = () => {

        if (!aboutWin) {
            aboutWin = new BrowserWindow({
                width: 300,
                height: 150,
                resizable: false,
                frame: false,
                parent: win,
                modal: true,
                webPreferences: {
                    nodeIntegration: true
                },
            });
github MarshallOfSound / Google-Play-Music-Desktop-Player-UNOFFICIAL- / src / main / features / core / tray.js View on Github external
const setContextMenu = (track) => {
  const contextMenu = Menu.buildFromTemplate([
    {
      label: 'Service',
      enabled: false,
    },
    {
      label: TranslationProvider.query('tray-label-gpm'),
      click: () => {
        // DEV: default to the other service so it will switch if not set.
        const currentService = Settings.get('service', 'youtube-music');
        if (currentService !== 'google-play-music') {
          Settings.set('service', 'google-play-music');
          mainWindow.hide();
          mainWindow.reload();
        }
      },
    },
github joe-re / cafe-pitch / src / browser / menu.ts View on Github external
click: function() { mainWindow.getBrowserWindow().webContents.toggleDevTools(); }
        }
      ]
    }
  ] as Electron.MenuItemOptions[];
  if (process.platform === "darwin" ) {
    menuItems.unshift(
      {
        label: "CafePitch",
        submenu: [
          { label: "Quit", accelerator: "CmdOrCtrl+Q", click: () => app.quit() }
        ]
      }
    );
  }
  Menu.setApplicationMenu(Menu.buildFromTemplate(menuItems));
};
github patrikx3 / onenote / src / electron / main / create / menu.js View on Github external
},
    ]

    if (process.env.APPIMAGE !== undefined) {
        template[6].submenu.push({type: 'separator'})
        template[6].submenu.push({
                label: global.p3x.onenote.lang.menu.help.checkUpdates,
                click: () => {
                    const {autoUpdater} = require("electron-updater");
                    autoUpdater.checkForUpdatesAndNotify();
                }
            },
        )
    }

    const menu = Menu.buildFromTemplate(template)
    Menu.setApplicationMenu(menu)
}
github Eugeny / terminus / app / lib / app.ts View on Github external
],
            },
            {
                role: 'help',
                submenu: [
                    {
                        label: 'Website',
                        click () {
                            shell.openExternal('https://eugeny.github.io/terminus')
                        },
                    },
                ],
            }
        ]

        Menu.setApplicationMenu(Menu.buildFromTemplate(template))
    }
}
github Aveek-Saha / MusicPlayer / main.js View on Github external
function createMenuOther(openFolder, theme, info) {
  var menu = Menu.buildFromTemplate([openFolder, theme, info])
  Menu.setApplicationMenu(menu)
}
github yeoman / yeoman-app / src / browser / appmenu.js View on Github external
ApplicationMenu.prototype.attachToWindow = function () {
  this.menu = Menu.buildFromTemplate(_.deepClone(this.template));
  Menu.setApplicationMenu(this.menu);
};
github tangrams / tangram-play / electron.js View on Github external
},
      {
        label: 'Zoom',
        role: 'zoom',
      },
      {
        type: 'separator',
      },
      {
        label: 'Bring All to Front',
        role: 'front',
      },
    ];
  }

  const menu = Menu.buildFromTemplate(template);
  Menu.setApplicationMenu(menu);
}
github andreas-mausch / whatsapp-viewer / main.js View on Github external
app.on('ready', () => {
  const template = [{
    label: 'File',
    submenu: [{
      label: 'Open',
      click() {}
    }]
  }];
  const menu = Menu.buildFromTemplate(template);
  Menu.setApplicationMenu(menu);

  mainWindow = new BrowserWindow({
    height: 720,
    width: 1024
  });

  mainWindow.loadURL('file://' + __dirname + '/index.html');
});
github MyCryptoHQ / MyCrypto / electron-app / main / contextMenu.ts View on Github external
if (isDevelopment) {
    ctxMenuTmpl = ctxMenuTmpl.concat([
      { type: 'separator' },
      {
        label: 'Inspect Element',
        click: () => {
          window.webContents.inspectElement(props.x, props.y);
          if (window.webContents.isDevToolsOpened()) {
            window.webContents.devToolsWebContents.focus();
          }
        }
      }
    ]);
  }

  const ctxMenu = Menu.buildFromTemplate(ctxMenuTmpl);

  const popupOpts: PopupOptions = {
    window,
    x: props.x,
    y: props.y
  };

  ctxMenu.popup(popupOpts);
}