2017-12-13 5 views
0

2つのブラウザが必要ですウィンドウ1つはメインウィンドウ、もう1つは子ウィンドウです私は子ウィンドウを設定したいです - メニューはメインウィンドウに反映されません。別のブラウザウィンドウは電子js内で異なるメニューオプションを持つ必要があります

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 

答えて

0

私はあなたが求めて何を正確にわからないが、私はあなたが子ウィンドウ上のメインウィンドウと異なるmenuBarmenuBarを設定したい伝えることができるものから。

あなたはこのようなwin.setMenu(menu)でこれを行うことができます。

const mainWindowMenuBar = Menu.buildFromTemplate(<Main window template>); 
const childWindowMenuBar = Menu.buildFromTemplate(<Child window template>); 

mainWindow.setMenu(mainWindowMenuBar); 

childWindow.setMenu(childWindowMenuBar); 

Docs

+0

おかげでマイク、それは私のためにうまく働きました。! – dhanasekar

関連する問題