Multiple context menus


#1

Hey guys,

Am day 3 on my electron journey! and its awesome!!

Am adding an event listener on 3 ids and showing a context menu. At the same time a context menu for the whole window (lets call global). While the menus are working fine when invoking, the global menu is showing up on left click in the individual context menus while choosing the options.

Here is the video

The js file looks like this…
Am I allowed to do this ? Not sure if its a bug.

// area 1 menu
document.getElementById('area-1').addEventListener('contextmenu', function(ev) {
  ev.preventDefault();
  menu1.popup(ev.x, ev.y);
  return false;
});

// area 2 menu
document.getElementById('area-2').addEventListener('contextmenu', function(ev) {
  ev.preventDefault();
  menu2.popup(ev.x, ev.y);
  return false;
});

// area 3 menu
document.getElementById('area-3').addEventListener('contextmenu', function(ev) {
  ev.preventDefault();
  menu3.popup(ev.x, ev.y);
  return false;
});

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