'How to disable and re-enable menu bar

I would like to disable the menu bar (make it grey and unopenable). How to do that?

I tried the following code but it removes the menu bar instead of disabling it.

Menu.setApplicationMenu(null);


Solution 1:[1]

Currently (being Electron v18.1.0) , you can't disable top level menu items.

See Github issue # 8703 Menu enabled/visible property doesn't affect top-level menu items for more information.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 midnight-coding