throw new Error('Unknown menu type') if MenuItem.types.indexOf(@type) is -1
@commandId = ++nextCommandId
- @click = ->
+ @click = =>
if typeof click is 'function'
- click()
+ click.apply this, arguments
else if typeof selector is 'string'
Menu.sendActionToFirstResponder selector
isCommandIdEnabled: (commandId) => @commandsMap[commandId]?.enabled
isCommandIdVisible: (commandId) => @commandsMap[commandId]?.visible
getAcceleratorForCommandId: (commandId) => @commandsMap[commandId]?.accelerator
- executeCommand: (commandId) => @commandsMap[commandId]?.click()
+ executeCommand: (commandId) =>
+ activeItem = @commandsMap[commandId]
+ activeItem.click(activeItem) if activeItem?
@items.splice pos, 0, item
@commandsMap[item.commandId] = item