mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-12-26 10:00:50 +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?
|
else if focusedBrowserWindow?
|
||||||
# Note: We sometimes display non-"AtomWindow" windows, for things like
|
# Note: We sometimes display non-"AtomWindow" windows, for things like
|
||||||
# raw message contents. Ensure that these also get to run window commands
|
# raw message contents. Ensure that these also get to run window commands
|
||||||
unless global.application.sendCommandToFirstResponder(command)
|
unless @sendCommandToFirstResponder(command)
|
||||||
switch command
|
switch command
|
||||||
when 'window:reload' then focusedBrowserWindow.reload()
|
when 'window:reload' then focusedBrowserWindow.reload()
|
||||||
when 'window:toggle-dev-tools' then focusedBrowserWindow.toggleDevTools()
|
when 'window:toggle-dev-tools' then focusedBrowserWindow.toggleDevTools()
|
||||||
|
|
|
@ -101,23 +101,22 @@ class WindowEventHandler
|
||||||
|
|
||||||
@handleNativeKeybindings()
|
@handleNativeKeybindings()
|
||||||
|
|
||||||
# Wire commands that should be handled by the native menu
|
# Wire commands that should be handled by Chromium for elements with the
|
||||||
# for elements with the `.override-key-bindings` class.
|
# `.override-key-bindings` class.
|
||||||
handleNativeKeybindings: ->
|
handleNativeKeybindings: ->
|
||||||
menu = null
|
menu = null
|
||||||
bindCommandToAction = (command, action) =>
|
bindCommandToAction = (command, action) =>
|
||||||
@subscribe $(document), command, (event) ->
|
@subscribe $(document), command, (event) ->
|
||||||
unless event.target.webkitMatchesSelector('.override-key-bindings')
|
unless event.target.webkitMatchesSelector('.override-key-bindings')
|
||||||
menu ?= require('remote').require('menu')
|
atom.getCurrentWindow().webContents[action]()
|
||||||
menu.sendActionToFirstResponder(action)
|
|
||||||
true
|
true
|
||||||
|
|
||||||
bindCommandToAction('core:copy', 'copy:')
|
bindCommandToAction('core:copy', 'copy')
|
||||||
bindCommandToAction('core:cut', 'cut:')
|
bindCommandToAction('core:cut', 'cut')
|
||||||
bindCommandToAction('core:paste', 'paste:')
|
bindCommandToAction('core:paste', 'paste')
|
||||||
bindCommandToAction('core:undo', 'undo:')
|
bindCommandToAction('core:undo', 'undo')
|
||||||
bindCommandToAction('core:redo', 'redo:')
|
bindCommandToAction('core:redo', 'redo')
|
||||||
bindCommandToAction('core:select-all', 'selectAll:')
|
bindCommandToAction('core:select-all', 'selectAll')
|
||||||
|
|
||||||
onKeydown: (event) ->
|
onKeydown: (event) ->
|
||||||
atom.keymaps.handleKeyboardEvent(event)
|
atom.keymaps.handleKeyboardEvent(event)
|
||||||
|
|
Loading…
Reference in a new issue