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 .
JavaScript
x
32
32
1
app.on('ready', function() {
2
// Create new window
3
// this assign the mainwindow variable as a browserwindow with
4
// default parameter value which will take the entire page
5
mainWindow = new BrowserWindow({});
6
childWindow = new BroserWindow({});
7
// Load html in window
8
// the below function will load the html into the window using the
9
//Command pathname
10
mainWindow.loadURL(url.format({
11
pathname: path.join(__dirname, 'mainWindow.html'),
12
protocol: 'file:',
13
slashes: true
14
}));
15
childWindow.loadURL(url.format({
16
pathname: path.join(__dirname, 'childWindow.html'),
17
protocol: 'file:',
18
slashes: true
19
}));
20
/ /
21
Quit app when closed
22
mainWindow.on('closed', function() {
23
app.quit();
24
});
25
// Build menu from template
26
const mainMenu = Menu.buildFromTemplate(mainMenuTemplate);
27
// Insert menu
28
Menu.setApplicationMenu(mainMenu);
29
});
30
//here i need to set the menu option only to the child window
31
//not the main window
32
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:
JavaScript
1
7
1
const mainWindowMenuBar = Menu.buildFromTemplate(<Main window template>);
2
const childWindowMenuBar = Menu.buildFromTemplate(<Child window template>);
3
4
mainWindow.setMenu(mainWindowMenuBar);
5
6
childWindow.setMenu(childWindowMenuBar);
7