]> khamidou — GitHub mirrors - electron.git/commitdiff
When calling menu item's click callback, pass the item object.
authorCheng Zhao <zcbenz@gmail.com>
Wed, 14 Aug 2013 04:51:47 +0000 (12:51 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 14 Aug 2013 04:51:47 +0000 (12:51 +0800)
browser/api/lib/menu-item.coffee
browser/api/lib/menu.coffee

index 2764a0b45a95f9dcd844e44ed6eb479fcccbeb82..aeae1f57620a8c202204afbffad160bdece2a05c 100644 (file)
@@ -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
 
index d4d2dafbf2a8a25c03ea91c78e648312bd2f0507..52c5f2426dad050ba43ee2e82e3aa18d88962b01 100644 (file)
@@ -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