@graphty/graphty-element / index / SelectionManager
Class: SelectionManager ​
Defined in: graphty-element/src/managers/SelectionManager.ts:38
Manages which nodes and edges are selected, as a view over the session's selection.
The single-node surface (select, deselect, getSelectedNode, isSelected, selectById) is what the element, the app and the XR input path have always called, and it keeps working: select replaces the selection with one node, which is exactly what a click has always done. The set-algebra surface belongs to the session's selection API, which this class writes to.
Implements ​
Constructors ​
Constructor ​
new SelectionManager(
eventManager):SelectionManager
Defined in: graphty-element/src/managers/SelectionManager.ts:57
Creates a new selection manager
Parameters ​
eventManager ​
Event manager for emitting selection events
Returns ​
SelectionManager
Methods ​
bindSelection() ​
bindSelection(
selection):void
Defined in: graphty-element/src/managers/SelectionManager.ts:94
Hand this view the session's selection to read and write.
One selection per session, shared by every view of the dataset: binding is how this view joins that rather than keeping a second, disagreeing answer.
Parameters ​
selection ​
SelectionOwner
The session's selection.
Returns ​
void
deselect() ​
deselect():
void
Defined in: graphty-element/src/managers/SelectionManager.ts:189
Deselect everything. Emits a selection-changed event if anything was selected.
Returns ​
void
dispose() ​
dispose():
void
Defined in: graphty-element/src/managers/SelectionManager.ts:69
Dispose the selection manager and clear the selection it is showing
Returns ​
void
Implementation of ​
getSelectedNode() ​
getSelectedNode():
Node|null
Defined in: graphty-element/src/managers/SelectionManager.ts:102
Get the currently selected node.
Returns ​
Node | null
The first selected node, or null if nothing is selected.
init() ​
init():
Promise<void>
Defined in: graphty-element/src/managers/SelectionManager.ts:62
Initialize the selection manager
Returns ​
Promise<void>
Implementation of ​
isSelected() ​
isSelected(
node):boolean
Defined in: graphty-element/src/managers/SelectionManager.ts:132
Check if a specific node is currently selected.
Parameters ​
node ​
The node to check.
Returns ​
boolean
True if the node is selected, false otherwise.
onEdgesRemoved() ​
onEdgesRemoved(
ids):void
Defined in: graphty-element/src/managers/SelectionManager.ts:226
Handle edge removal, which is what removing a node now cascades into.
The session's masks are keyed by dense index and self-heal at the next COMPACTING freeze, but a removal that triggers no freeze would leave a removed edge in the selection until something else forced one -- so the selection would report an edge the graph no longer has.
Parameters ​
ids ​
readonly string[]
The ids of the edges that were removed.
Returns ​
void
onNodeRemoved() ​
onNodeRemoved(
node):void
Defined in: graphty-element/src/managers/SelectionManager.ts:207
Handle node removal. Should be called when a node is removed from the graph. If the removed node was selected, it leaves the selection.
Parameters ​
node ​
The node being removed.
Returns ​
void
select() ​
select(
node):void
Defined in: graphty-element/src/managers/SelectionManager.ts:152
Select a node, replacing whatever was selected before.
That is what a click means, and it is what this method has always done. Adding to, removing from, toggling or intersecting the selection is the session selection's apply, which takes the same five verbs for every target shape.
Parameters ​
node ​
The node to select.
Returns ​
void
selectById() ​
selectById(
nodeId):boolean
Defined in: graphty-element/src/managers/SelectionManager.ts:170
Select a node by its ID. Requires DataManager to be set via setDataManager().
Parameters ​
nodeId ​
string | number
The ID of the node to select.
Returns ​
boolean
True if the node was found and selected, false if not found.
setDataManager() ​
setDataManager(
dataManager):void
Defined in: graphty-element/src/managers/SelectionManager.ts:83
Set the DataManager reference. Required for selectById() functionality.
Parameters ​
dataManager ​
The data manager instance
Returns ​
void