return mate::ConvertFromV8(isolate(), val, accelerator);
}
-void Menu::ExecuteCommand(int command_id, int event_flags) {
- execute_command_.Run(command_id);
+void Menu::ExecuteCommand(int command_id, int flags) {
+ execute_command_.Run(
+ mate::internal::CreateEventFromFlags(isolate(), flags),
+ command_id);
}
void Menu::MenuWillShow(ui::SimpleMenuModel* source) {
base::Callback<bool(int)> is_enabled_;
base::Callback<bool(int)> is_visible_;
base::Callback<v8::Local<v8::Value>(int)> get_accelerator_;
- base::Callback<void(int)> execute_command_;
+ base::Callback<void(v8::Local<v8::Value>, int)> execute_command_;
base::Callback<void()> menu_will_show_;
DISALLOW_COPY_AND_ASSIGN(Menu);
### new MenuItem(options)
* `options` Object
- * `click` Function - Will be called with `click(menuItem, browserWindow)` when
- the menu item is clicked
+ * `click` Function - Will be called with
+ `click(menuItem, browserWindow, event)` when the menu item is clicked
* `role` String - Define the action of the menu item; when specified the
`click` property will be ignored
* `type` String - Can be `normal`, `separator`, `submenu`, `checkbox` or
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
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)
}
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.