-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes an issue where kiosk mode doesn't work properly.
- Loading branch information
1 parent
7ee5ee8
commit ce54e8d
Showing
2 changed files
with
94 additions
and
93 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,103 @@ | ||
const { Menu } = require("electron"); | ||
const templateFunc = require("./menuTemplate"); | ||
const { windows } = require("./multiWindow"); | ||
const { Menu, BrowserWindow, app } = require("electron"); | ||
const { windows, addWindow } = require("./multiWindow"); | ||
const { getLoadedUrl } = require("./loadedUrl"); | ||
|
||
module.exports.setMenubar = function setMenubar() { | ||
function templateFunc() { | ||
var template = [ | ||
{ | ||
label: "Application", | ||
submenu: [ | ||
{ | ||
label: "About Application", | ||
selector: "orderFrontStandardAboutPanel:" | ||
}, | ||
{ | ||
label: "Quit", | ||
accelerator: "CmdOrCtrl+Alt+Q", | ||
click: function() { | ||
app.quit(); | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
label: "File", | ||
submenu: [ | ||
{ | ||
label: "New Window", | ||
accelerator: "CmdOrCtrl+N", | ||
click: function() { | ||
addWindow({ loadedUrl: getLoadedUrl() }); | ||
} | ||
}, | ||
{ | ||
label: "Reload", | ||
accelerator: "CmdOrCtrl+Alt+R", | ||
click: function() { | ||
windows.forEach(mainWindow => { | ||
mainWindow && mainWindow.reload(); | ||
}); | ||
} | ||
}, | ||
|
||
{ | ||
label: "Kiosk", | ||
accelerator: "CmdOrCtrl+Alt+K", | ||
click: function() { | ||
if (windows[0] && windows[0].isKiosk()) { | ||
windows.forEach(mainWindow => { | ||
mainWindow.setKiosk(false); | ||
setMenubar(); | ||
}); | ||
} else { | ||
windows.forEach(mainWindow => { | ||
mainWindow.setKiosk(true); | ||
|
||
clearMenubar(); | ||
}); | ||
} | ||
} | ||
}, | ||
{ | ||
label: "Dev Tools", | ||
accelerator: "CmdOrCtrl+Alt+I", | ||
click: function() { | ||
const focused = BrowserWindow.getFocusedWindow(); | ||
focused && focused.webContents.openDevTools(); | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
label: "Edit", | ||
submenu: [ | ||
{ label: "Cut", accelerator: "CmdOrCtrl+X", selector: "cut:" }, | ||
{ label: "Copy", accelerator: "CmdOrCtrl+C", selector: "copy:" }, | ||
{ label: "Paste", accelerator: "CmdOrCtrl+V", selector: "paste:" }, | ||
{ | ||
label: "Select All", | ||
accelerator: "CmdOrCtrl+A", | ||
selector: "selectAll:" | ||
} | ||
] | ||
} | ||
]; | ||
return template; | ||
} | ||
|
||
function setMenubar() { | ||
const template = templateFunc(); | ||
Menu.setApplicationMenu(Menu.buildFromTemplate(template)); | ||
windows.forEach(w => { | ||
w.setMenuBarVisibility(true); | ||
w.setAutoHideMenuBar(false); | ||
}); | ||
}; | ||
} | ||
|
||
module.exports.clearMenubar = function clearMenubar() { | ||
function clearMenubar() { | ||
Menu.setApplicationMenu(null); | ||
}; | ||
} | ||
|
||
module.exports.setMenubar = setMenubar; | ||
|
||
module.exports.clearMenubar = clearMenubar; |