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