How to use the electron.Menu.setApplicationMenu 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 olymp / olymp / packages / electron / main.es6 View on Github external
function createWindow() {
  log.info('Starting');
  if (template.length) {
    const menu = Menu.buildFromTemplate(template);
    Menu.setApplicationMenu(menu);
  }

  if (process.env.NODE_ENV === 'production') {
    log.info('Starting updater..');

    autoUpdater
      .checkForUpdates()
      .then(() => {
        log.info('Promise fulfilled');
      })
      .catch(reason => {
        log.info(`Handle rejected promise (${reason.stack || reason}) here.`);
      });
  }
  log.info('Creating browser window');
  // Create the browser window.
github belltown / violetbug / source / main.js View on Github external
// Monospace font size set from config file
        //defaultMonospaceFontSize: 14,

        // Make sure that requestAnimationFrame still runs even when
        // window is minimized, as it is used to trigger updates
        // to device output panel
        backgroundThrottling: false,

        // Needed for CSS 'grid' support
        experimentalFeatures: true
      }
    })

    // Create the main application menu
    Menu.setApplicationMenu(VBMenu.createAppMenu())

    // Display the Developer Tools (not in production release)
    //global.mainWindow.webContents.openDevTools()

    // Load the app's index.html file from disk
    global.mainWindow.loadURL(`file://${__dirname}/index.html`)

    // The 'resize' event is emitted when the window's dimensions are changed
    global.mainWindow.on('resize', () => {
      if (!global.mainWindow.isMaximized()) {
        [config.width, config.height] = global.mainWindow.getSize()
      }
    })

    // The 'move' event is emitted when the window is repositioned
    global.mainWindow.on('move', () => {
github epiqueras / electrify / template / _src / _main / _index.js View on Github external
app.on('ready', () => {
  // Restore last windows
  config.get('windowStates').forEach((state, index) => createWindow(windows, index, state))

  // If there wasn't any windows, create a new one
  if (windows.length === 0) createWindow(windows, 0)

  // Create and attach Menu
  Menu.setApplicationMenu(createAppMenu(windows))

  // If in production, initialize auto updater
  if (process.env.NODE_ENV !== 'development') initializeAutoUpdater()
})
github hundredrabbits / Orca / desktop / main.js View on Github external
app.injectMenu = function (menu) {
  try {
    Menu.setApplicationMenu(Menu.buildFromTemplate(menu))
  } catch (err) {
    console.warn('Cannot inject menu.')
  }
}
github jelleoverbeek / abstract-todo / public / electron.js View on Github external
{ label: "Cut", accelerator: "CmdOrCtrl+X", selector: "cut:" },
        { label: "Copy", accelerator: "CmdOrCtrl+C", selector: "copy:" },
        { label: "Paste", accelerator: "CmdOrCtrl+V", selector: "paste:" },
        { label: "Select All", accelerator: "CmdOrCtrl+A", selector: "selectAll:" },
        {
          label: "Dev tools",
          accelerator: "CmdOrCtrl+J",
          click() {
            mainWindow.webContents.openDevTools();
          }
        }
      ]
    }
  ];

  Menu.setApplicationMenu(Menu.buildFromTemplate(template));
}
github mdyna / mdyna-app / index.js View on Github external
controlStyle = null;
        break;
      case 'windows_nt':
        controlStyle = 'Windows';
        break;
      default:
        controlStyle = 'Linux';
        break;
    }
    if (osType.includes('windows')) {
      controlStyle = 'Windows';
    }
  }
  global.controlsStyle = controlStyle;
  if (osType === 'darwin') {
    Menu.setApplicationMenu(
      Menu.buildFromTemplate([
        {
          label: 'Edit',
          submenu: [
            { role: 'undo' },
            { role: 'redo' },
            { type: 'separator' },
            { role: 'cut' },
            { role: 'copy' },
            { role: 'paste' },
            { role: 'pasteandmatchstyle' },
            { role: 'delete' },
            { role: 'selectall' },
          ],
        },
      ]),
github klinker24 / google-calendar-desktop / resources / js / menu.js View on Github external
const win = windowProvider.getWindow();
          const menuVisible = win.isMenuBarVisible();

          win.autoHideMenuBar = menuVisible;
          win.setMenuBarVisibility(!menuVisible);

          browserviewPreparer.setBounds(win, windowProvider.getBrowserView());
        },
        label: "Toggle Menu Bar Visibility",
      });
    }

    const window = windowProvider.getWindow();
    const menu = Menu.buildFromTemplate(template);

    Menu.setApplicationMenu(menu);
    
    window.autoHideMenuBar = true;
    window.setMenuBarVisibility(false);

    browserviewPreparer.setBounds(window, windowProvider.getBrowserView());
  }
github pocketnetteam / pocketnet.gui / main.js View on Github external
width: mainScreen.size.width,
        height: mainScreen.size.height,

        title: "POCKETNET v" + app.getVersion(),
        webSecurity : false,

        icon: defaultIcon,
    });

    win.maximize();
    let isHidden = process.argv.find(function(el) { return el == '--hidden'; })
    if (isHidden) {
        win.hide();
    }

    Menu.setApplicationMenu(null)

    win.loadFile('index_el.html')

    electronLocalshortcut.register(win, 'CommandOrControl+Shift+I', () => {
		win.webContents.toggleDevTools()
	});

    win.webContents.on('new-window', function(event, url) {
        event.preventDefault();
        open(url);
    });

    win.on('close', function(e) {
        if (!willquit) {
            e.preventDefault();
            win.hide();
github ipfs-shipyard / ipfs-desktop / src / app-menu.js View on Github external
export default function () {
  const menu = Menu.buildFromTemplate(template)
  Menu.setApplicationMenu(menu)
}
github Almenon / AREPL-electron / src / electron / main.js View on Github external
autoUpdater.on('update-available', (info) => {
    const updateAvailibleMenu = {
      label: "New update availible",
      submenu: [{
        label: "release info",
        click: () => { require('electron').shell.openExternal('https://github.com/Almenon/AREPL/releases') }
      }]
    }
    menuTemplate.push(updateAvailibleMenu)
    Menu.setApplicationMenu(Menu.buildFromTemplate(menuTemplate))
  })
  autoUpdater.on('update-not-available', (info) => {