Skip to content

Commit

Permalink
When calling menu item's click callback, pass the item object.
Browse files Browse the repository at this point in the history
  • Loading branch information
zcbenz committed Aug 14, 2013
1 parent f267a78 commit 971b72c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions browser/api/lib/menu-item.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class MenuItem
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

Expand Down
4 changes: 3 additions & 1 deletion browser/api/lib/menu.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ Menu::insert = (pos, item) ->
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

Expand Down

0 comments on commit 971b72c

Please sign in to comment.