How to set up application menu in electron?

Viewed 3427

if i start the electron-quick-start application, i get a full OSX menu:

enter image description here

I then add this code, mostly copied from docs, to my main.js:

const Menu = require('menu');                                                                                                                                                                            
const MenuItem = require('menu-item');
var mainmenu = new Menu();
mainmenu.append(new MenuItem({ label: 'MenuItem1', click: function() { console.log('item 1 clicked'); } }));
Menu.setApplicationMenu(mainmenu);

I also tried to use menu template code from the electron menu docs, with the exact same disappointing result:

enter image description here

I also tried to add the code above to index.html, literally copying the code on Menu's doc. Same thing.

Any idea what is wrong?

1 Answers
Related