mirror of
https://github.com/atom/atom.git
synced 2026-02-08 21:55:05 -05:00
Test that global key bindings defined on root view work in the editor.
This commit is contained in:
@@ -12,9 +12,9 @@ class KeyEventHandler
|
||||
bindKeys: (selector, bindings) ->
|
||||
@bindingSets.push(new BindingSet(selector, bindings))
|
||||
|
||||
handleKeypress: (event) ->
|
||||
handleKeyEvent: (event) ->
|
||||
currentNode = $(event.target)
|
||||
while currentNode
|
||||
while currentNode isnt document
|
||||
candidateBindingSets = @bindingSets.filter (set) -> currentNode.is(set.selector)
|
||||
candidateBindingSets.sort (a, b) -> b.specificity - a.specificity
|
||||
for bindingSet in candidateBindingSets
|
||||
|
||||
@@ -6,6 +6,7 @@ Buffer = require 'buffer'
|
||||
Editor = require 'editor'
|
||||
FileFinder = require 'file-finder'
|
||||
Project = require 'project'
|
||||
KeyEventHandler = require 'key-event-handler'
|
||||
|
||||
module.exports =
|
||||
class RootView extends Template
|
||||
@@ -17,7 +18,11 @@ class RootView extends Template
|
||||
@subview 'editor', Editor.build()
|
||||
|
||||
viewProperties:
|
||||
keyEventHandler: null
|
||||
|
||||
initialize: ({url}) ->
|
||||
@keyEventHandler = new KeyEventHandler
|
||||
@editor.keyEventHandler = @keyEventHandler
|
||||
@bindKey 'meta+s', => @editor.save()
|
||||
@bindKey 'meta+w', => window.close()
|
||||
@bindKey 'meta+t', => @toggleFileFinder()
|
||||
|
||||
Reference in New Issue
Block a user