javascriptreactjselectronmenubarelectron-react

How to remove menu bar from the window that opens with an external URL of an Electron application


I have the below code to remove menu bar from the window that opens with an external URL of an Electron application.

windowObject.webContents.setWindowOpenHandler(() => ({
  action: 'allow',
  overrideBrowserWindowOptions: {
    autoHideMenuBar: true,
  },
}));

But the menu pops up when "Alt" key is pressed which is a short-key conflict with my application. So, is there any way to prevent this behavior ? Thanks in advance.


Solution

  • Try doing this, it should fix it depending on what version of eletron your using

    const {app, BrowserWindow, Menu} = require('electron')
    Menu.setApplicationMenu(false)
    

    if the previous code does not work try doing this

        let mainWindow = new BrowserWindow({
            autoHideMenuBar: true
        })