In my electron app, a user can open different windows.
I have the menu initialized when the main window is created like so:
const menuContents = Menu.buildFromTemplate(menuTemplate(mainWindow))
Menu.setApplicationMenu(menuContents)
However, when a user clicks a link and opens a new window, this same menu bar still appears in that window. I would like to change it and/or completely remove it.
How would I do that?
It's possible:
Example for Menus
In Renderer or Main Proccess make two functions with menu templates like this:
function createMenu(){
var menu = Menu.buildFromTemplate([
{
//your menu items
}
])
Menu.setApplicationMenu(menu);
}
function createMenuwin(){
var menu = Menu.buildFromTemplate([
{
//your other window menu items
}
])
Menu.setApplicationMenu(menu);
}
function openIMG(path){
win = new BrowserWindow({
width: 800,
height: 550,
frame: true,
vibrancy: 'medium-light',
});
win.loadFile(path);
createMenuwin();
win.on('close', () =>{
createMenu();
})
}
createmenuwin()
win.on('close', () =>{})
createMenu();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With