Merge pull request #7770 from atom/ns-only-forward-menu-action-on-osx

Handle native chromium undo, redo, cut, copy, paste, selectAll on all platforms
This commit is contained in:
Nathan Sobo 2015-07-07 19:26:04 -05:00
commit 4091fa9e78

View File

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