mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2025-01-08 16:19:17 +03:00
Write focusNext/PreviousPane in terms of activateNext/PreviousPane
"Activate" is the model level equivalent of focus.
This commit is contained in:
parent
0d66c68fe8
commit
4a7b43f609
@ -42,7 +42,7 @@ describe "PaneContainerView", ->
|
||||
describe ".focusPreviousPane()", ->
|
||||
it "focuses the pane preceding the focused pane or the last pane if no pane has focus", ->
|
||||
container.attachToDom()
|
||||
$(document.body).focus() # clear focus
|
||||
container.getPanes()[0].focus() # activate first pane
|
||||
|
||||
container.focusPreviousPane()
|
||||
expect(pane3.activeItem).toMatchSelector ':focus'
|
||||
|
@ -106,22 +106,7 @@ class PaneContainerView extends View
|
||||
@viewForModel(@model.paneForUri(uri))
|
||||
|
||||
focusNextPane: ->
|
||||
panes = @getPanes()
|
||||
if panes.length > 1
|
||||
currentIndex = panes.indexOf(@getFocusedPane())
|
||||
nextIndex = (currentIndex + 1) % panes.length
|
||||
panes[nextIndex].focus()
|
||||
true
|
||||
else
|
||||
false
|
||||
@model.activateNextPane()
|
||||
|
||||
focusPreviousPane: ->
|
||||
panes = @getPanes()
|
||||
if panes.length > 1
|
||||
currentIndex = panes.indexOf(@getFocusedPane())
|
||||
previousIndex = currentIndex - 1
|
||||
previousIndex = panes.length - 1 if previousIndex < 0
|
||||
panes[previousIndex].focus()
|
||||
true
|
||||
else
|
||||
false
|
||||
@model.activatePreviousPane()
|
||||
|
@ -49,8 +49,20 @@ class PaneContainer extends Model
|
||||
currentIndex = panes.indexOf(@activePane)
|
||||
nextIndex = (currentIndex + 1) % panes.length
|
||||
panes[nextIndex].activate()
|
||||
true
|
||||
else
|
||||
@activePane = null
|
||||
false
|
||||
|
||||
activatePreviousPane: ->
|
||||
panes = @getPanes()
|
||||
if panes.length > 1
|
||||
currentIndex = panes.indexOf(@activePane)
|
||||
previousIndex = currentIndex - 1
|
||||
previousIndex = panes.length - 1 if previousIndex < 0
|
||||
panes[previousIndex].activate()
|
||||
true
|
||||
else
|
||||
false
|
||||
|
||||
onRootChanged: (root) =>
|
||||
@unsubscribe(@previousRoot) if @previousRoot?
|
||||
|
@ -218,10 +218,10 @@ class WorkspaceView extends View
|
||||
@panes.getActiveView()
|
||||
|
||||
# Public: Focuses the previous pane by id.
|
||||
focusPreviousPane: -> @panes.focusPreviousPane()
|
||||
focusPreviousPane: -> @model.activatePreviousPane()
|
||||
|
||||
# Public: Focuses the next pane by id.
|
||||
focusNextPane: -> @panes.focusNextPane()
|
||||
focusNextPane: -> @model.activateNextPane()
|
||||
|
||||
# Public:
|
||||
#
|
||||
|
@ -12,7 +12,8 @@ class Workspace extends Model
|
||||
Serializable.includeInto(this)
|
||||
|
||||
@delegatesProperty 'activePane', 'activePaneItem', toProperty: 'paneContainer'
|
||||
@delegatesMethod 'getPanes', 'saveAll', toProperty: 'paneContainer'
|
||||
@delegatesMethod 'getPanes', 'saveAll', 'activateNextPane', 'activatePreviousPane',
|
||||
toProperty: 'paneContainer'
|
||||
|
||||
@properties
|
||||
paneContainer: -> new PaneContainer
|
||||
|
Loading…
Reference in New Issue
Block a user