Ensure focus returns to the editor when file finder closes.

We just capture focusout events on root view… if anything other than the editors text area lost focus, we focus the editor again. This will likely need refinement when we add more widgets to the system, but its enough to make the fuzzy finder behave appropriately.
This commit is contained in:
Corey Johnson & Nathan Sobo
2012-01-11 13:13:37 -08:00
parent 83a68dbbb0
commit 17ad7a26e7
4 changed files with 52 additions and 40 deletions

View File

@@ -37,7 +37,7 @@ class Editor extends Template
@aceEditor.setTheme(require "ace/theme/twilight")
@aceEditor.setKeyboardHandler
handleKeyboard: (data, hashId, keyString, keyCode, event) =>
if event and @keyEventHandler?.handleKeyEvent(event)
if event and @keyEventHandler and @keyEventHandler.handleKeyEvent(event) == false
{ command: { exec: -> }}
else
null
@@ -45,6 +45,9 @@ class Editor extends Template
getAceSession: ->
@aceEditor.getSession()
focus: ->
@aceEditor.focus()
save: ->
if @buffer.url
@buffer.save()

View File

@@ -32,6 +32,9 @@ class RootView extends Template
@on 'toggle-file-finder', => @toggleFileFinder()
@on 'focusout', (e) =>
@editor.focus() unless e.target is @editor.find('textarea')[0]
createProject: (url) ->
if url
@project = new Project(fs.directory(url))