FocusedContentStore
Summary
The FocusedContentStore provides access to the objects currently selected or otherwise focused in the window. Normally, focus would be maintained internally by components that show models. The FocusedContentStore makes the concept of selection public so that you can observe focus changes and trigger your own changes to focus.
Since {FocusedContentStore} is a Flux-compatible Store, you do not call setters on it directly. Instead, use Actions::setFocus or Actions::setCursorPosition to set focus. The FocusedContentStore observes these models, changes it's state, and broadcasts to it's observers.
Note: The {FocusedContentStore} triggers when a focused model is changed, even if it's ID has not. For example, if the user has a {Thread} selected and removes a tag, {FocusedContentStore} will trigger so you can fetch the new version of the {Thread}. If you observe the {FocusedContentStore} properly, you should always have the latest version of the the selected object.
Standard Collections:
- thread
- file
Example: Observing the Selected Thread
@unsubscribe = FocusedContentStore.listen(@_onFocusChanged, @)
...
# Called when focus has changed, or when the focused model has been modified.
_onFocusChanged: ->
thread = FocusedContentStore.focused('thread')
if thread
console.log("#{thread.subject} is selected!")
else
console.log("No thread is selected!")
Instance Methods
focused(collection)
Parameters
Argument | Description |
---|---|
collection | The {String} name of a collection. Standard collections are listed above. |
Returns
Return Values |
---|
Returns the focused {Model} in the collection specified, or undefined if no item is focused. |
focusedId(collection)
Argument | Description |
---|---|
collection | The {String} name of a collection. Standard collections are listed above. |
Returns
Return Values |
---|
Returns the ID of the focused {Model} in the collection specified, or undefined if no item is focused. |
didFocusUsingClick(collection)
Argument | Description |
---|---|
collection | The {String} name of a collection. Standard collections are listed above. |
Returns
Return Values |
---|
Returns true if the item for the collection was focused via a click or false otherwise. |
keyboardCursor(collection)
Argument | Description |
---|---|
collection | The {String} name of a collection. Standard collections are listed above. |
Returns
Return Values |
---|
Returns the {Model} the keyboard is currently focused on in the collection specified. Keyboard focus is not always separate from primary focus (selection). You can use keyboardCursorEnabled to determine whether keyboard focus is enabled. |
keyboardCursorId(collection)
Argument | Description |
---|---|
collection | The {String} name of a collection. Standard collections are listed above. |
Returns
Return Values |
---|
Returns the ID of the {Model} the keyboard is currently focused on in the collection specified. Keyboard focus is not always separate from primary focus (selection). You can use keyboardCursorEnabled to determine whether keyboard focus is enabled. |
keyboardCursorEnabled()
Return Values |
---|
Returns a {Boolean} - `true` if the keyboard cursor concept applies in the current {WorkspaceStore} layout mode. The keyboard cursor is currently only enabled in `list` mode. |