Root view can receive focus if there is no active editor.

This allows basic key bindings to work without an editor.
This commit is contained in:
Nathan Sobo 2012-03-23 10:44:25 -06:00
parent 4c74e2187d
commit 49be6986a0
2 changed files with 22 additions and 1 deletions

View File

@ -33,6 +33,21 @@ describe "RootView", ->
rootView = new RootView
expect(rootView.activeEditor().buffer.url).toBeUndefined()
describe "focus", ->
it "can receive focus if there is no active editor, but otherwise hands off focus to the active editor", ->
rootView = new RootView(require.resolve 'fixtures')
rootView.attachToDom()
expect(rootView).toMatchSelector(':focus')
rootView.activeEditor() # lazily create an editor
expect(rootView).not.toMatchSelector(':focus')
expect(rootView.activeEditor().isFocused).toBeTruthy()
rootView.focus()
expect(rootView).not.toMatchSelector(':focus')
expect(rootView.activeEditor().isFocused).toBeTruthy()
describe "split editor panes", ->
editor1 = null

View File

@ -13,7 +13,7 @@ CommandPanel = require 'command-panel'
module.exports =
class RootView extends View
@content: ->
@div id: 'root-view', =>
@div id: 'root-view', tabindex: -1, =>
@div id: 'panes', outlet: 'panes'
editors: null
@ -32,6 +32,12 @@ class RootView extends View
@on 'toggle-file-finder', => @toggleFileFinder()
@on 'show-console', -> window.showConsole()
@one 'attach', => @focus()
@on 'focus', (e) =>
if @editors.length
@activeEditor().focus()
false
@commandPanel = new CommandPanel({rootView: this})
createProject: (path) ->