Skip to content

Commit

Permalink
Fixes an issue where kiosk mode doesn't work properly.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderson1993 committed May 8, 2019
1 parent 7ee5ee8 commit ce54e8d
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 93 deletions.
86 changes: 0 additions & 86 deletions src/helpers/menuTemplate.js

This file was deleted.

101 changes: 94 additions & 7 deletions src/helpers/setMenubar.js
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;

0 comments on commit ce54e8d

Please sign in to comment.