fix(first-responder): Apply changes from Atom to window-event-handler

Applies a4d716c491 to our code.

Fixes https://sentry.nylas.com/sentry/edgehill/group/1716/
This commit is contained in:
Ben Gotow 2015-08-03 11:56:12 -07:00
parent b148ea54e2
commit 5843c260f3
2 changed files with 10 additions and 11 deletions

View file

@ -328,7 +328,7 @@ class Application
else if focusedBrowserWindow?
# Note: We sometimes display non-"AtomWindow" windows, for things like
# raw message contents. Ensure that these also get to run window commands
unless global.application.sendCommandToFirstResponder(command)
unless @sendCommandToFirstResponder(command)
switch command
when 'window:reload' then focusedBrowserWindow.reload()
when 'window:toggle-dev-tools' then focusedBrowserWindow.toggleDevTools()

View file

@ -101,23 +101,22 @@ class WindowEventHandler
@handleNativeKeybindings()
# Wire commands that should be handled by the native menu
# for elements with the `.override-key-bindings` class.
# Wire commands that should be handled by Chromium for elements with the
# `.override-key-bindings` class.
handleNativeKeybindings: ->
menu = null
bindCommandToAction = (command, action) =>
@subscribe $(document), command, (event) ->
unless event.target.webkitMatchesSelector('.override-key-bindings')
menu ?= require('remote').require('menu')
menu.sendActionToFirstResponder(action)
atom.getCurrentWindow().webContents[action]()
true
bindCommandToAction('core:copy', 'copy:')
bindCommandToAction('core:cut', 'cut:')
bindCommandToAction('core:paste', 'paste:')
bindCommandToAction('core:undo', 'undo:')
bindCommandToAction('core:redo', 'redo:')
bindCommandToAction('core:select-all', 'selectAll:')
bindCommandToAction('core:copy', 'copy')
bindCommandToAction('core:cut', 'cut')
bindCommandToAction('core:paste', 'paste')
bindCommandToAction('core:undo', 'undo')
bindCommandToAction('core:redo', 'redo')
bindCommandToAction('core:select-all', 'selectAll')
onKeydown: (event) ->
atom.keymaps.handleKeyboardEvent(event)