diff --git a/src/pane-model.coffee b/src/pane-model.coffee index c39174083..def6d3a6c 100644 --- a/src/pane-model.coffee +++ b/src/pane-model.coffee @@ -10,6 +10,7 @@ class PaneModel extends Model @properties items: -> [] activeItem: null + focused: false constructor: -> super @@ -18,6 +19,7 @@ class PaneModel extends Model serializeParams: -> items: compact(@items.map((item) -> item.serialize?())) activeItemUri: @activeItem?.getUri?() + focused: @focused deserializeParams: (params) -> {items, activeItemUri} = params @@ -25,6 +27,12 @@ class PaneModel extends Model params.activeItem = find params.items, (item) -> item.getUri?() is activeItemUri params + focus: -> + @focused = true + + blur: -> + @focused = false + # Public: Returns all contained views. getItems: -> clone(@items) diff --git a/src/pane.coffee b/src/pane.coffee index f9bb2b25c..8896d95bd 100644 --- a/src/pane.coffee +++ b/src/pane.coffee @@ -32,11 +32,13 @@ class Pane extends View toProperty: 'model' previousActiveItem: null + focusOnAttach: false # Private: initialize: (args...) -> if args[0]?.model? - {@model, @focusOnAttach} = args[0] + {@model} = args[0] + @focusOnAttach = @model.focused else @model = new PaneModel(items: args) @@ -53,7 +55,8 @@ class Pane extends View @subscribe @model, 'item-destroyed', @onItemDestroyed @subscribe this, 'focus', => @activeView?.focus(); false - @subscribe this, 'focusin', => @makeActive() + @subscribe this, 'focusin', => @makeActive(); @model.focus() + @subscribe this, 'focusout', => @model.blur() @command 'pane:save-items', => @saveItems() @command 'pane:show-next-item', => @showNextItem() @@ -82,7 +85,6 @@ class Pane extends View serializeParams: -> model: @model.serialize() - focusOnAttach: @is(':has(:focus)') # Private: afterAttach: (onDom) ->