mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-12-25 17:42:16 +08:00
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:
parent
b148ea54e2
commit
5843c260f3
2 changed files with 10 additions and 11 deletions
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue