ELECTRON-588 - Fix keyboard shortcut issue on Windows 10 (#419)

This commit is contained in:
Kiran Niranjan 2018-07-09 13:33:19 +05:30 committed by Vishwas Shashidhar
parent a18f3eb64c
commit 37194505bb

View File

@ -234,6 +234,13 @@ function doCreateMainWindow(initialUrl, initialBounds, isCustomTitleBar) {
}
}
// Event needed to hide native menu bar on Windows 10 as we use custom menu bar
mainWindow.webContents.once('did-start-loading', () => {
if (isWindows10() && mainWindow && !mainWindow.isDestroyed()) {
mainWindow.setMenuBarVisibility(false);
}
});
// content can be cached and will still finish load but
// we might not have network connectivity, so warn the user.
mainWindow.webContents.on('did-finish-load', function () {
@ -426,6 +433,14 @@ function doCreateMainWindow(initialUrl, initialBounds, isCustomTitleBar) {
let webContents = newWinOptions.webContents;
// Event needed to hide native menu bar
webContents.once('did-start-loading', () => {
let browserWin = BrowserWindow.fromWebContents(webContents);
if (isWindowsOS && browserWin && !browserWin.isDestroyed()) {
browserWin.setMenuBarVisibility(false);
}
});
webContents.once('did-finish-load', function () {
let browserWin = BrowserWindow.fromWebContents(webContents);
@ -909,9 +924,7 @@ eventEmitter.on('language-changed', (opts) => {
function rebuildMenu(language) {
setLanguage(language);
menu = electron.Menu.buildFromTemplate(getTemplate(app));
if (!isWindows10()) {
electron.Menu.setApplicationMenu(menu);
}
electron.Menu.setApplicationMenu(menu);
}
function setLanguage(language) {