Bind keydown on root view to catch events that aren't handled by ace

Also fixed a bug where the GlobalKeymap wasn't returning true when it
matched a binding, which caused key events to be processed twice when
they bubbled out of the editor and hit the root view.
This commit is contained in:
Nathan Sobo
2012-01-10 23:54:14 -08:00
committed by Corey Johnson & Nathan Sobo
parent 7f4120ce36
commit 2a80a72d64
6 changed files with 28 additions and 23 deletions

View File

@@ -38,7 +38,7 @@ class Editor extends Template
@aceEditor.setKeyboardHandler
handleKeyboard: (data, hashId, keyString, keyCode, event) =>
if event and @keyEventHandler?.handleKeyEvent(event)
{command: {exec: ->}}
{ command: { exec: -> }}
else
null

View File

@@ -20,6 +20,6 @@ class GlobalKeymap
for bindingSet in candidateBindingSets
if command = bindingSet.commandForEvent(event)
$(event.target).trigger(command)
return
return true
currentNode = currentNode.parent()
false

View File

@@ -22,7 +22,7 @@ class RootView extends Template
initialize: ({url}) ->
@globalKeymap = new GlobalKeymap
@on 'keydown', (e) => @globalKeymap.handleKeyEvent(e)
@editor.keyEventHandler = @globalKeymap
@globalKeymap.bindKeys '*'
@@ -30,7 +30,7 @@ class RootView extends Template
'meta-w': 'close'
'meta-t': 'toggle-file-finder'
@on 'toggle-file-finder', (e) => @toggleFileFinder()
@on 'toggle-file-finder', => @toggleFileFinder()
if url
@project = new Project(fs.directory(url))