Add quit role

This commit is contained in:
Kevin Sawicki 2016-06-20 17:03:48 -07:00
parent f45e6c6c38
commit a16d907684

View file

@ -15,7 +15,8 @@ rolesMap = {
selectall: 'selectAll', selectall: 'selectAll',
minimize: 'minimize', minimize: 'minimize',
close: 'close', close: 'close',
delete: 'delete' delete: 'delete',
quit: 'quit'
} }
// Maps methods that should be called directly on the BrowserWindow instance // Maps methods that should be called directly on the BrowserWindow instance
@ -24,12 +25,16 @@ methodInBrowserWindow = {
close: true close: true
} }
const methodInApp = {
quit: true
}
MenuItem = (function () { MenuItem = (function () {
MenuItem.types = ['normal', 'separator', 'submenu', 'checkbox', 'radio'] MenuItem.types = ['normal', 'separator', 'submenu', 'checkbox', 'radio']
function MenuItem (options) { function MenuItem (options) {
var click, ref var click, ref
const Menu = require('electron').Menu const {app, Menu} = require('electron')
click = options.click click = options.click
this.selector = options.selector this.selector = options.selector
this.type = options.type this.type = options.type
@ -73,7 +78,9 @@ MenuItem = (function () {
} }
if (this.role && rolesMap[this.role] && process.platform !== 'darwin' && (focusedWindow != null)) { if (this.role && rolesMap[this.role] && process.platform !== 'darwin' && (focusedWindow != null)) {
methodName = rolesMap[this.role] methodName = rolesMap[this.role]
if (methodInBrowserWindow[methodName]) { if(methodInApp[methodName]) {
return app[methodName]()
} else if (methodInBrowserWindow[methodName]) {
return focusedWindow[methodName]() return focusedWindow[methodName]()
} else { } else {
return (ref2 = focusedWindow.webContents) != null ? ref2[methodName]() : void 0 return (ref2 = focusedWindow.webContents) != null ? ref2[methodName]() : void 0