From e3e1ed41ca8c9910064c6c829c541b8d308e622a Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 21 Jun 2016 09:31:17 -0700 Subject: [PATCH] Add togglefullscreen role --- lib/browser/api/menu-item.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/browser/api/menu-item.js b/lib/browser/api/menu-item.js index f38ab970d695..de5aab28ef10 100644 --- a/lib/browser/api/menu-item.js +++ b/lib/browser/api/menu-item.js @@ -14,13 +14,17 @@ const rolesMap = { minimize: 'minimize', close: 'close', delete: 'delete', - quit: 'quit' + quit: 'quit', + togglefullscreen: 'toggleFullScreen' } // Maps methods that should be called directly on the BrowserWindow instance const methodInBrowserWindow = { minimize: true, - close: true + close: true, + toggleFullScreen: function (window) { + window.setFullScreen(!window.isFullScreen()) + } } const methodInApp = { @@ -79,7 +83,11 @@ const MenuItem = (function () { if (methodInApp[methodName]) { return app[methodName]() } else if (methodInBrowserWindow[methodName]) { - return focusedWindow[methodName]() + if (typeof methodName === 'function') { + return methodName(focusedWindow) + } else { + return focusedWindow[methodName]() + } } else { const {webContents} = focusedWindow return webContents != null ? webContents[methodName]() : void 0