[SOLVED] How do I get rid of the preset menu bar that appears after debugging app


#1

How do I get rid of preset menu bar?


Thanks


#2

I assume you are using electron-prebuilt or something similar (e.g. downloaded Electron from the release page) and cannot modify Electron’s source directly?

If so, you can use BrowserWindow.setMenu(menu) to set the menu. As the documentation says, simply pass null if you don’t want a menu bar.

Unfortunately, a side-effect of disabling the menu is that the Developer Tools shortcut, by default Ctrl+Shift+I, no longer works, so (as far as I know) you cannot open the Developer Tools anymore with the menu disabled, which is rather annoying during development. To solve this I hide the menu by default and allow it to be shown by pressing Alt when I am working on the app. For an example see the code snippet below.

app.on('ready', function() {
  // Create the browser window.
  browserWindow = new BrowserWindow({
    width: 1200,
    height: 675,
    title: 'MyApp'
  });

  // Disable the Menu.
  // browserWindow.setMenu(null);

  // Hide the menu bar, but allow it to be brought up by pressing `alt`.
  browserWindow.setMenuBarVisibility(false);
  browserWindow.setAutoHideMenuBar(true);

  // ...
});

#3

Thanks – 10 character fill –