clean up menuWillShow
This commit is contained in:
parent
1cd53768ab
commit
f9c3123f5f
1 changed files with 12 additions and 18 deletions
|
@ -88,15 +88,15 @@ Menu.prototype._init = function () {
|
|||
this.items = []
|
||||
this.delegate = {
|
||||
isCommandIdChecked: (commandId) => {
|
||||
var command = this.commandsMap[commandId]
|
||||
const command = this.commandsMap[commandId]
|
||||
return command != null ? command.checked : undefined
|
||||
},
|
||||
isCommandIdEnabled: (commandId) => {
|
||||
var command = this.commandsMap[commandId]
|
||||
const command = this.commandsMap[commandId]
|
||||
return command != null ? command.enabled : undefined
|
||||
},
|
||||
isCommandIdVisible: (commandId) => {
|
||||
var command = this.commandsMap[commandId]
|
||||
const command = this.commandsMap[commandId]
|
||||
return command != null ? command.visible : undefined
|
||||
},
|
||||
getAcceleratorForCommandId: (commandId, useDefaultAccelerator) => {
|
||||
|
@ -106,7 +106,7 @@ Menu.prototype._init = function () {
|
|||
if (useDefaultAccelerator) return command.getDefaultRoleAccelerator()
|
||||
},
|
||||
getIconForCommandId: (commandId) => {
|
||||
var command = this.commandsMap[commandId]
|
||||
const command = this.commandsMap[commandId]
|
||||
return command != null ? command.icon : undefined
|
||||
},
|
||||
executeCommand: (event, commandId) => {
|
||||
|
@ -115,23 +115,17 @@ Menu.prototype._init = function () {
|
|||
command.click(event, BrowserWindow.getFocusedWindow(), webContents.getFocusedWebContents())
|
||||
},
|
||||
menuWillShow: () => {
|
||||
// Make sure radio groups have at least one menu item seleted.
|
||||
var checked, group, id, j, len, radioItem, ref1
|
||||
ref1 = this.groupsMap
|
||||
for (id in ref1) {
|
||||
group = ref1[id]
|
||||
checked = false
|
||||
for (j = 0, len = group.length; j < len; j++) {
|
||||
radioItem = group[j]
|
||||
if (!radioItem.checked) {
|
||||
continue
|
||||
}
|
||||
// Make sure radio groups have at least one menu item selected
|
||||
for (let id in this.groupsMap) {
|
||||
const group = this.groupsMap[id]
|
||||
const checked = false
|
||||
for (let idx = 0; idx < group.length; idx++) {
|
||||
const radioItem = group[idx]
|
||||
if (!radioItem.checked) continue
|
||||
checked = true
|
||||
break
|
||||
}
|
||||
if (!checked) {
|
||||
v8Util.setHiddenValue(group[0], 'checked', true)
|
||||
}
|
||||
if (!checked) v8Util.setHiddenValue(group[0], 'checked', true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue