I wish to create a resizable node, with a main shape (rectangle) and some external shape ‘decoration’. Here is an example where I have used a Spot node following by a textblock and custom geometry to create the look of a multi-document icon as follows:
Here is my code:
var nodeTemplate =
$(go.Node, "Spot",
{
selectionAdorned: true
, resizable: true
//, desiredSize: new go.Size(100, 100)
}
, $(go.Shape , "Rectangle", // spot positions in the the mopde are aligned with respect to this
{
fill: "lightgray"
, strokeWidth: 2
, portId: ""
, cursor: "crosshair"
, fromLinkable: true, fromLinkableSelfNode: true, fromLinkableDuplicates: true
, toLinkable: true, toLinkableSelfNode: true, toLinkableDuplicates: true
, fromSpot: go.Spot.AllSides
, toSpot: go.Spot.AllSides
}
)
, $(go.TextBlock,
{
name: "TitleTextBlock"
, alignment: new go.Spot(0.5,0, 0, 5)
, alignmentFocus: go.Spot.Top
, font: "bold 16px sans-serif"
, editable: true
, text: "some node title"
, background: "lightcyan"
, wrap: go.TextBlock.WrapFit
}
)
, $(go.Shape ,
{ // this geometry creates the multiple document shadow
geometry: go.Geometry.parse("M-95,0 h95v-95 M-90,5 h95 v- 95")
, strokeWidth: 2
, alignment: new go.Spot(1, 1, 10, 10)
, alignmentFocus: go.Spot.BottomRight
}
)
); // end Node
I have two problems; which I can’t seem to solve:
-
As soon as I resize the node the custom geometry seems to disappear behind the rectangle. I thought the whole point of the Spot is that you make it relative to the rectangle position?
-
The text in the node title is not wrapping. I would like it to be contained inside the node, which means either make it wrap or force the node to resize when you edit the title; or even when the node is initially drawn with the default text. How could you achieve either of these things?