Call role method on focused web contents

This commit is contained in:
Kevin Sawicki 2016-07-13 12:18:44 -07:00
parent 06e595e7cc
commit f9a8bd3ea5
3 changed files with 10 additions and 16 deletions

View file

@ -1,7 +1,6 @@
'use strict'
const BrowserWindow = require('electron').BrowserWindow
const MenuItem = require('electron').MenuItem
const {BrowserWindow, MenuItem, webContents} = require('electron')
const EventEmitter = require('events').EventEmitter
const v8Util = process.atomBinding('v8_util')
const bindings = process.atomBinding('menu')
@ -117,8 +116,10 @@ Menu.prototype._init = function () {
return command != null ? command.icon : undefined
},
executeCommand: (event, commandId) => {
var command = this.commandsMap[commandId]
return command != null ? command.click(event, BrowserWindow.getFocusedWindow()) : undefined
const command = this.commandsMap[commandId]
if (command == null) return
command.click(event, BrowserWindow.getFocusedWindow(), webContents.getFocusedWebContents())
},
menuWillShow: () => {
// Make sure radio groups have at least one menu item seleted.