The default behavior is that when the user clicks on a GraphObject, that object’s GraphObject.part will be selected. That’s the simple case, and it’s all controlled by ClickSelectingTool. Here’s how it handles the mouse-up of a click:
ClickSelectingTool.prototype.doMouseUp = function() {
if (this.isActive) {
this.standardMouseSelect();
var handled = this.standardMouseClick();
if (!handled) {
if (this.diagram !== null && this.diagram.lastInput.isTouchEvent) {
this.diagram.toolManager.doToolTip();
}
}
}
this.stopTool();
};
So you might want to either override this method or ClickSelectingTool.standardMouseSelect. FYI, that is defined as:
Tool.prototype.standardMouseSelect = function() {
var diagram = this.diagram;
if (diagram === null || !diagram.allowSelect) return;
var e = diagram.lastInput;
var curobj = diagram.findPartAt(e.documentPoint, false); // to select containing Group if Part.canSelect() is false
if (curobj !== null) {
if (e.meta || e.control) { // toggle the part's selection
diagram.raiseDiagramEvent('ChangingSelection');
var part = curobj;
while (part !== null && !part.canSelect()) part = part.containingGroup;
if (part !== null) part.isSelected = !part.isSelected;
diagram.raiseDiagramEvent('ChangedSelection');
} else if (e.shift) { // add the part to the selection
if (!curobj.isSelected) {
diagram.raiseDiagramEvent('ChangingSelection');
var part = curobj;
while (part !== null && !part.canSelect()) part = part.containingGroup;
if (part !== null) part.isSelected = true;
diagram.raiseDiagramEvent('ChangedSelection');
}
} else {
if (!curobj.isSelected) {
var part = curobj;
while (part !== null && !part.canSelect()) part = part.containingGroup;
if (part !== null) diagram.select(part); // also raises ChangingSelection/Finished
}
}
} else if (e.left && !(e.meta || e.control) && !e.shift) {
// left click on background with no modifier: clear selection
diagram.clearSelection(); // also raises ChangingSelection/Finished
}
};