Add "event" parameter for "click" handler of MenuItem

This commit is contained in:
Cheng Zhao 2016-06-22 11:22:14 +09:00
parent e6327fb015
commit 8d08e215b2
5 changed files with 11 additions and 9 deletions

View file

@ -72,7 +72,7 @@ const MenuItem = (function () {
throw new Error('Unknown menu type ' + this.type)
}
this.commandId = ++nextCommandId
this.click = (focusedWindow) => {
this.click = (event, focusedWindow) => {
// Manually flip the checked flags when clicked.
if (this.type === 'checkbox' || this.type === 'radio') {
this.checked = !this.checked
@ -91,7 +91,7 @@ const MenuItem = (function () {
return webContents != null ? webContents[methodName]() : void 0
}
} else if (typeof click === 'function') {
return click(this, focusedWindow)
return click(this, focusedWindow, event)
} else if (typeof this.selector === 'string' && process.platform === 'darwin') {
return Menu.sendActionToFirstResponder(this.selector)
}

View file

@ -114,9 +114,9 @@ Menu.prototype._init = function () {
var command = this.commandsMap[commandId]
return command != null ? command.icon : undefined
},
executeCommand: (commandId) => {
executeCommand: (event, commandId) => {
var command = this.commandsMap[commandId]
return command != null ? command.click(BrowserWindow.getFocusedWindow()) : undefined
return command != null ? command.click(event, BrowserWindow.getFocusedWindow()) : undefined
},
menuWillShow: () => {
// Make sure radio groups have at least one menu item seleted.