When calling menu item's click callback, pass the item object.
This commit is contained in:
parent
f267a7812f
commit
971b72c2b6
2 changed files with 5 additions and 3 deletions
|
@ -20,9 +20,9 @@ class MenuItem
|
||||||
throw new Error('Unknown menu type') if MenuItem.types.indexOf(@type) is -1
|
throw new Error('Unknown menu type') if MenuItem.types.indexOf(@type) is -1
|
||||||
|
|
||||||
@commandId = ++nextCommandId
|
@commandId = ++nextCommandId
|
||||||
@click = ->
|
@click = =>
|
||||||
if typeof click is 'function'
|
if typeof click is 'function'
|
||||||
click()
|
click.apply this, arguments
|
||||||
else if typeof selector is 'string'
|
else if typeof selector is 'string'
|
||||||
Menu.sendActionToFirstResponder selector
|
Menu.sendActionToFirstResponder selector
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,9 @@ Menu::insert = (pos, item) ->
|
||||||
isCommandIdEnabled: (commandId) => @commandsMap[commandId]?.enabled
|
isCommandIdEnabled: (commandId) => @commandsMap[commandId]?.enabled
|
||||||
isCommandIdVisible: (commandId) => @commandsMap[commandId]?.visible
|
isCommandIdVisible: (commandId) => @commandsMap[commandId]?.visible
|
||||||
getAcceleratorForCommandId: (commandId) => @commandsMap[commandId]?.accelerator
|
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
|
@items.splice pos, 0, item
|
||||||
@commandsMap[item.commandId] = item
|
@commandsMap[item.commandId] = item
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue