Editor can have custom key event handler.

editor.keyEventHandler.handleKeyEvent is passed all key events. When it returns true, the event is not handled by Ace.
This commit is contained in:
Corey Johnson & Nathan Sobo
2012-01-10 15:32:13 -08:00
parent 7f3396c125
commit c3b5cd19ea
2 changed files with 52 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ class Editor extends Template
viewProperties:
aceEditor: null
buffer: null
keyEventHandler: null
initialize: () ->
@aceSessions = {}
@@ -34,6 +35,13 @@ class Editor extends Template
@aceEditor = ace.edit this[0]
@aceEditor.setTheme(require "ace/theme/twilight")
@aceEditor.setKeyboardHandler
handleKeyboard: (data, hashId, keyString, keyCode, e) =>
if @keyEventHandler?.handleKeyEvent(e)
{command: {exec: ->}}
else
null
getAceSession: ->
@aceEditor.getSession()