Hi Guru,
I’m trying to create dinamical ports over a group, but I can’t find an example that shows how to create those outside the main shape of the group… above what I get with my code:
and what I really need:
I need to create those ports when I drag and drop a node within that group.
Here’s the code for the group:
myDiagram.groupTemplate =
$(go.Group, "Auto",
{
background: "transparent",
ungroupable: true,
// highlight when dragging into the Group
mouseDragEnter: function(e, grp, prev) { highlightGroup(e, grp, true); },
mouseDragLeave: function(e, grp, next) { highlightGroup(e, grp, false); },
computesBoundsAfterDrag: true,
// when the selection is dropped into a Group, add the selected Parts into that Group;
// if it fails, cancel the tool, rolling back any changes
mouseDrop: finishDrop,
handlesDragDropForMembers: true, // don't need to define handlers on member Nodes and Links
// Groups containing Groups lay out their members horizontally
layout: makeLayout(false),
cursor: "move"
},
new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify),
new go.Binding("layout", "horiz", makeLayout),
new go.Binding("background", "isHighlighted", function(h) {
return h ? "rgba(0,255,0,0.6)" : "transparent";
}).ofObject(),
$(go.Shape, "Rectangle",
{ fill: null, stroke: defaultColor(false), strokeWidth: 2 },
new go.Binding("stroke", "horiz", defaultColor),
new go.Binding("stroke", "color")),
$(go.Panel, "Vertical", // title above Placeholder
$(go.Panel, "Horizontal", // button next to TextBlock
{
name: "hover-screenshot-panel",
stretch: go.GraphObject.Horizontal,
background: defaultColor(false),
portId: "totale",
// allows links to/from all sides
fromSpot: go.Spot.Right,
toSpot: go.Spot.Left,
fromLinkable: true,
toLinkable: true,
cursor:"pointer"
},
new go.Binding("background", "horiz", defaultColor),
new go.Binding("background", "color"),
$("SubGraphExpanderButton",
{ alignment: go.Spot.Right, margin: 5 }),
$(go.TextBlock,
{
alignment: go.Spot.Left,
editable: false,
margin: 5,
font: defaultFont(false),
opacity: 0.75, // allow some color to show through
stroke: "#404040"
},
new go.Binding("font", "horiz", defaultFont),
new go.Binding("text", "text").makeTwoWay())
), // end Horizontal Panel
$(go.Placeholder,
{
padding: 15,
alignment: go.Spot.TopLeft
})
), // end Vertical Panel
$(go.Panel, "Vertical",{alignment: new go.Spot(1, 0.5) },
new go.Binding("itemArray", "rightArray"),
{
//row: 3, column: 2,
itemTemplate:
$(go.Panel,
{
_side: "right",
fromSpot: go.Spot.Right, toSpot: go.Spot.Right,
fromLinkable: true, toLinkable: false,
cursor: "pointer",
contextMenu: portMenu
},
new go.Binding("portId", "portId"),
$(go.Shape, "Rectangle",
{
stroke: null, strokeWidth: 0,
desiredSize: portSize,
margin: new go.Margin(1, 0),
fill: "blue"
}
)
//new go.Binding("fill", "portColor"))
) // end itemTemplate
}
) // end Vertical Panel
);
Is also possible to write text within those ports?
Thx in advance
F