I need the 2 browser Window one is main Window and other one is child window i want to set the child Window – menu that menu should not reflect on the main window .
app.on('ready', function() { // Create new window // this assign the mainwindow variable as a browserwindow with // default parameter value which will take the entire page mainWindow = new BrowserWindow({}); childWindow = new BroserWindow({}); // Load html in window // the below function will load the html into the window using the //Command pathname mainWindow.loadURL(url.format({ pathname: path.join(__dirname, 'mainWindow.html'), protocol: 'file:', slashes: true })); childWindow.loadURL(url.format({ pathname: path.join(__dirname, 'childWindow.html'), protocol: 'file:', slashes: true })); / / Quit app when closed mainWindow.on('closed', function() { app.quit(); }); // Build menu from template const mainMenu = Menu.buildFromTemplate(mainMenuTemplate); // Insert menu Menu.setApplicationMenu(mainMenu); }); //here i need to set the menu option only to the child window //not the main window
Advertisement
Answer
I’m not exactly sure what your asking but from what I can tell you want to set a menuBar
on the main window and a different menuBar
on the child window.
You can do this with win.setMenu(menu)
like this:
const mainWindowMenuBar = Menu.buildFromTemplate(<Main window template>); const childWindowMenuBar = Menu.buildFromTemplate(<Child window template>); mainWindow.setMenu(mainWindowMenuBar); childWindow.setMenu(childWindowMenuBar);