How to disable the default menubar


#1

After the 0.27 update there is a default menubar, so now I have 2 bars (my own + the default)
I can’t find where / how to disable it?


#2

Found it already:
You can outcomment it in the resources/main.js file
the part starting at
// Create default menu.


#3

I think this should be configurable without hacking electron’s startup script. The default menu can be an eyesore under Linux (wherever there isn’t a unified menu), and unnecessary if the developer wants to implement an html menu for their application.


#4

I’m using the latest version 0.30.1 at the time of writing.

This will remove the menu bar completely -

browserWindow.setMenu(null);

In your case, maybe try setting the menu to null and then create your menu and set it as the menu?


#5

It’s working.

Thanks :smile:


#6

Thanks @Abijeet

But if you want to disable it globally (for new windows too) you have to:

  electron.app.on('browser-window-created',function(e,window) {
      window.setMenu(null);
  });

#7

Where do I put this exactly? -EDIT-
I figured it out and found out it works like this

app.on(‘ready’, function() {
app.on(‘browser-window-created’,function(e,window) {
window.setMenu(null);
});


#8

Here how I do it,
win = new BrowserWindow({
width: 600,
height: 600
})
win.setMenu(null);


#9

I used

mainWindow = new BrowserWindow({width: 300, height: 300, frame: false})


#10

setMenu(null) will remove the menu, but the not frame, whereas frame: false will remove the entire interface.


#11

You can also do it llike this. All the Window that are opening in this apps will be MenuLess.

app.on(‘ready’, createWindow)

app.on(‘browser-window-created’,function(e,window) {
window.setMenu(null);
});


#12

But console is disabled when I set menu to null. Is there a way of doing this without disabling console?


#13

Hi brunoczim

my main.js file looks like this and dev tools is still working

const electron = require('electron');

const app = electron.app;
const BrowserWindow = electron.BrowserWindow;

// Keep reference of main window because of GC
var mainWindow = null;

// Quit when all windows are closed
app.on(‘window-all-closed’, function() {
app.quit();
});

// When application is ready, create application window
app.on(‘ready’, function() {

// Create main window
// Other options available at:
// http://electron.atom.io/docs/latest/api/browser-window/#new-browserwindow-options
mainWindow = new BrowserWindow({
    name: "ea-todo",
    width: 900,
    height: 900,
    skipTaskbar: true,
    toolbar: false
});

mainWindow.setMenu(null);

// Target HTML file which will be opened in window
mainWindow.loadURL('file://' + __dirname + "/app/index.html");

// Uncomment to use Chrome developer tools
mainWindow.webContents.openDevTools({detach:true});

// Cleanup when window is closed
mainWindow.on('closed', function() {
    mainWindow = null;
});

});


#14

when i use
window.setMenu(null);
the shortcut ctrl + r , don’t work anymore