Selects Management Model
The graph model also provides the element selection management model, by which the elements will be selected or the selection may be cancelled.
#selectionModel :Q.SelectionModel - element selection model
- Selection element: model.selectionModel.select(…);
- Cancel element selection: model.selectionModel.unselect(…);
- Clear element selection status: model.selectionModel.clear();
Selection change events
Provides corresponding dispatcher for selection change event, applicable to selection change event of monitoring elements
#selectionChangeDispatcher :Q.Dispatcher - Dispatcher of element selection change event
Example
Monitor selection change events
var model = graph.graphModel;
var a = new Q.Node('A');
model.add(a);
var b = new Q.Node('B');
model.add(b);
model.selectionChangeDispatcher.addListener(function(evt){
Q.log(evt.kind);
});
var selectionModel = model.selectionModel;
selectionModel.select(a);
selectionModel.unselect(a);
selectionModel.select(b);
selectionModel.clear();
Print results
add
remove
add
clear