Skip to content

Instantly share code, notes, and snippets.

@erickzhao
Created October 16, 2020 03:45
Show Gist options
  • Select an option

  • Save erickzhao/eb76391231904b36f5ebf7fb83c5840b to your computer and use it in GitHub Desktop.

Select an option

Save erickzhao/eb76391231904b36f5ebf7fb83c5840b to your computer and use it in GitHub Desktop.
Electron Fiddle Gist
<!DOCTYPE html>
<html lang="en">
<head>
<title>Menu Example</title>
</head>
<body>
<h1>Menu Example</h1>
</body>
</html>
// Create native application menus and context menus.
//
// For more info, see:
// https://electronjs.org/docs/api/menu
const { app, BrowserWindow, Menu, MenuItem } = require('electron')
app.on('ready', () => {
const mainWindow = new BrowserWindow({ height: 600, width: 600 })
mainWindow.loadFile('index.html')
const menu = new Menu();
menu.append(new MenuItem( {
label: 'Electron',
submenu: [
{ role: 'undo' },
{ role: 'redo' },
{ type: 'separator' },
{ role: 'cut' },
{ role: 'copy' },
{ role: 'paste' }
]
}));
Menu.setApplicationMenu(menu)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment