2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-11-11 07:41:04 +00:00

Implement navigating backward and forward from the application menu

This commit is contained in:
Jia Hao 2016-01-23 14:15:25 +08:00
parent eabe6de892
commit e0de7bf463
2 changed files with 19 additions and 2 deletions

View File

@ -43,7 +43,7 @@ function createMainWindow(options, onAppQuit, setDockBadge) {
mainWindow.webContents.send('change-zoom', currentZoom);
};
createMenu(options.nativefierVersion, onAppQuit, onZoomIn, onZoomOut);
createMenu(options.nativefierVersion, onAppQuit, mainWindow.webContents.goBack, mainWindow.webContents.goForward, onZoomIn, onZoomOut);
if (options.userAgent) {
mainWindow.webContents.setUserAgent(options.userAgent);

View File

@ -6,10 +6,12 @@ var shell = electron.shell;
*
* @param {string} nativefierVersion
* @param {electron.app.quit} onQuit should be from app.quit
* @param {function} onGoBack
* @param {electron} onGoForward
* @param {function} onZoomIn
* @param {function} onZoomOut
*/
function createMenu(nativefierVersion, onQuit, onZoomIn, onZoomOut) {
function createMenu(nativefierVersion, onQuit, onGoBack, onGoForward, onZoomIn, onZoomOut) {
if (Menu.getApplicationMenu())
return;
@ -55,6 +57,18 @@ function createMenu(nativefierVersion, onQuit, onZoomIn, onZoomOut) {
{
label: 'View',
submenu: [
{
label: 'Back',
click: function () {
onGoBack();
}
},
{
label: 'Forward',
click: function () {
onGoForward();
}
},
{
label: 'Reload',
accelerator: 'CmdOrCtrl+R',
@ -63,6 +77,9 @@ function createMenu(nativefierVersion, onQuit, onZoomIn, onZoomOut) {
focusedWindow.reload();
}
},
{
type: 'separator'
},
{
label: 'Toggle Full Screen',
accelerator: (function () {