Merge pull request #6385 from electron/only-use-role-accelerator-in-app-menu

Only use default role accelerator in app menu
This commit is contained in:
Cheng Zhao 2016-07-08 11:22:21 +09:00 committed by GitHub
commit 6e81c55880
37 changed files with 233 additions and 155 deletions

View file

@ -31,7 +31,7 @@ const MenuItem = function (options) {
this.overrideReadOnlyProperty('type', 'normal')
this.overrideReadOnlyProperty('role')
this.overrideReadOnlyProperty('accelerator', roles.getDefaultAccelerator(this.role))
this.overrideReadOnlyProperty('accelerator')
this.overrideReadOnlyProperty('icon')
this.overrideReadOnlyProperty('submenu')
@ -66,6 +66,10 @@ const MenuItem = function (options) {
MenuItem.types = ['normal', 'separator', 'submenu', 'checkbox', 'radio']
MenuItem.prototype.getDefaultRoleAccelerator = function () {
return roles.getDefaultAccelerator(this.role)
}
MenuItem.prototype.overrideProperty = function (name, defaultValue) {
if (defaultValue == null) {
defaultValue = null

View file

@ -106,9 +106,11 @@ Menu.prototype._init = function () {
var command = this.commandsMap[commandId]
return command != null ? command.visible : undefined
},
getAcceleratorForCommandId: (commandId) => {
var command = this.commandsMap[commandId]
return command != null ? command.accelerator : undefined
getAcceleratorForCommandId: (commandId, useDefaultAccelerator) => {
const command = this.commandsMap[commandId]
if (command == null) return
if (command.accelerator != null) return command.accelerator
if (useDefaultAccelerator) return command.getDefaultRoleAccelerator()
},
getIconForCommandId: (commandId) => {
var command = this.commandsMap[commandId]