Using gojs, I would like to apply parameters only when the object is placed inside another object.
for example a panel should only have the padding added (or change value, from 0 to 25)
when placed inside a H Group.
is this possible?
looking at gojs docs I see SelectionGrouped
but not sure if this includes dropping the object into a H Group
myDiagram.nodeTemplateMap.add("j2",
$(go.Node, "Auto",
$(go.Panel, "auto", {padding:0},
$(go.Shape, "File"),
$(go.TextBlock, "This\n is a\n file", textStyle(),
new go.Binding("text", "text").makeTwoWay())
)
));
You can fire events when Parts are added to or removed from groups using Group.memberAdded and
memberRemoved` https://gojs.net/latest/api/symbols/Group.html#memberAdded
Or you can make a data binding on the Part (that isn't the Group) to do something different when its containingGroup
is not null. Example binding:
new go.Binding("margin", "containingGroup", function(a) {
if (a === null) return 5;
// otherwise its in a group:
return 15;
}).ofObject(),
See it live here: https://codepen.io/simonsarris/pen/LYNOpme?editors=1010