Include AtomWindow in command options

This ensures that all application commands can use it instead of relying
on the focused window.
This commit is contained in:
Kevin Sawicki
2014-04-17 11:36:19 -07:00
parent 020c5e795a
commit 9128041c20
2 changed files with 6 additions and 3 deletions

View File

@@ -140,7 +140,8 @@ class AtomApplication
@on 'application:open-file', -> @promptForPath(type: 'file')
@on 'application:open-folder', -> @promptForPath(type: 'folder')
@on 'application:open-dev', -> @promptForPath(devMode: true)
@on 'application:inspect', ({x,y}, atomWindow=@focusedWindow()) ->
@on 'application:inspect', ({x,y, atomWindow}) ->
atomWindow ?= @focusedWindow()
atomWindow?.browserWindow?.inspectElement(x, y)
@on 'application:open-documentation', -> shell.openExternal('https://atom.io/docs/latest/?app')
@@ -236,7 +237,7 @@ class AtomApplication
# atomWindow - The {AtomWindow} to send the command to.
# args - The optional arguments to pass along.
sendCommandToWindow: (command, atomWindow, args...) ->
unless @emit(command, args..., atomWindow)
unless @emit(command, args...)
if atomWindow?
atomWindow.sendCommand(command, args...)
else

View File

@@ -13,7 +13,9 @@ class ContextMenu
createClickHandlers: (template) ->
for item in template
if item.command
(item.commandOptions ?= {}).contextCommand = true
item.commandOptions ?= {}
item.commandOptions.contextCommand = true
item.commandOptions.atomWindow = @atomWindow
do (item) =>
item.click = =>
global.atomApplication.sendCommandToWindow(item.command, @atomWindow, item.commandOptions)