Hello! I am currently working on implementing a Node object that can have different selectable parts depending on whether or not the ports are expanded.
This is our base node, which should be selected with our circular port like below:
selected →
In order to achieve this, I had to add a hidden rectangular object on top of the node body and the circular port and set that as my selection object. This is fine, but the problem I’m facing happens when I want to expand the ports and the selection object should change to just be the node body.
should look like →
When the ports are expanded, updateTargetBindings is called on the body part to recalculate port positions, but the selection remains how it was originally. I have bindings set to both selectionObjectName and selectionAdornment to change up the selected object and adornment, but I have to first unselect the node, then reselect it in order to get this behavior. I’ve been searching through the API, and I feel like there must be a call I may be overlooking that should handle updating it at the same time the ports are being redrawn. (I’ve looked at updateAdornments, and that didn’t work either.)
Here is my code trimmed below if this helps:
public static HybridTemplate(
inputCircle: boolean = true,
handlers: Map<string, (...args: any) => void>
): GoNode {
return GO(
GoNode,
'Spot',
new Binding('selectionObjectName', '', (node: Node, _part: Part) => {
if ((inputCircle && node.inPorts?.expanded) || (!inputCircle && node.outPorts?.expanded)) {
return 'SHAPE';
}
return 'EXPANDEDSHAPE';
}),
new Binding('selectionAdornmentTemplate', '', (node: Node, _part: Part) => {
if ((inputCircle && node.inPorts?.expanded) || (!inputCircle && node.outPorts?.expanded)) {
return AdornmentTemplate.SquareNodeSelectionAdornment(handlers);
}
return AdornmentTemplate.HybridNodeSelectionAdornment(inputCircle, handlers);
}),
);
/** Other node properties */
}
Any help would be very appreciated- thanks!