Forward window focus when active element is body

This problem was when the focus element is detached
when navigating away from the window and when
the window is then given focus again nothing has
focus.

The solution is to use RootView's focus handler
on the window to bring focus to the editor or
other view when the document's active element
is the body meaning nothing inside the RootView
currently has focus.
This commit is contained in:
Kevin Sawicki
2012-12-27 21:53:43 -08:00
parent f07f42fc38
commit 575e34d5e4

View File

@@ -55,20 +55,24 @@ class RootView extends View
panesViewState: @panes.children().view()?.serialize()
extensionStates: @serializeExtensions()
handleEvents: ->
@on 'toggle-dev-tools', => atom.toggleDevTools()
@on 'focus', (e) =>
if @getActiveEditor()
@getActiveEditor().focus()
handleFocus: (e) ->
if @getActiveEditor()
@getActiveEditor().focus()
false
else
@setTitle(null)
focusableChild = this.find("[tabindex=-1]:visible:first")
if focusableChild.length
focusableChild.focus()
false
else
@setTitle(null)
focusableChild = this.find("[tabindex=-1]:visible:first")
if focusableChild.length
focusableChild.focus()
false
else
true
true
handleEvents: ->
@on 'toggle-dev-tools', => atom.toggleDevTools()
@on 'focus', (e) => @handleFocus(e)
$(window).on 'focus', (e) =>
@handleFocus(e) if document.activeElement is document.body
@on 'active-editor-path-change', (e, path) =>
@project.setPath(path) unless @project.getRootDirectory()