How do I add a menu?


#1

Hi,

How do I add a menu? This is my current code base:

indx.html

...
<body>
    <script src="js/menu.js"></script>
</body>
...

menu.js

var remote = require('remote');
var Menu = remote.require('menu');
var MenuItem = remote.require('menu-item');

var menu = new Menu();
menu.append(new MenuItem({ label: 'MenuItem1', click: function() { console.log('item 1 clicked'); } }));
menu.append(new MenuItem({ type: 'separator' }));
menu.append(new MenuItem({ label: 'MenuItem2', type: 'checkbox', checked: true }));

window.addEventListener('contextmenu', function (e) {
	e.preventDefault();
	menu.popup(remote.getCurrentWindow());
}, false);

Am i supposed to see a menu?


#2

Never mind, I didn’t understand what was meant by menu. I expected an action bar at the top of the frame like file, edit, etc… Instead it’s a context menu brought up with right clicking.