I’m able to set “isSelected” and “isHighlighted” without any problems, and the mouseEnter call seems to fine, but I can’t seem to remove the background when I mouseLeave the placholder…“text.background” seems to be working fine on mouseEnter. What am I missing? Also, do I need to do anything to get the links to show up connecting the nodes in the subgraph.
//called when the mouse enters the subgraph
function mouseEnterSubGraph (e, obj) {
console.log(obj);
var shape = obj.findObject("SHAPE");
shape.fill = "#DDF8BF";
shape.stroke = "#77B03B";
var text = obj.findObject("TEXT");
text.background = "#DDF8BF";
}
//called when the mouse leaves the subgraph
function mouseLeaveSubGraph (node){
var shape;
var text;
//check to see if the current node is selected or is highlighted and if it is then apply these styles
if(node.isSelected || node.isHighlighted){
shape = node.findObject("SHAPE");
shape.fill = "#E9F9D7";
text = node.findObject("TEXT");
text.background = "#E9F9D7"; //doesn't get applied
//if the node is not selected or highlighted apply these styles
} else {
shape = node.findObject("SHAPE");
shape.fill = "#FFF";
// shape.stroke = "#009BE1";
text = node.findObject("TEXT");
text.background = "#FFF"; //doesn't get applied
}
}
myDiagram2.groupTemplate =
graph(go.Group, "Auto",
// declare the Group.layout:
{
selectionAdorned: false,
mouseEnter: mouseEnterSubGraph,
mouseLeave: function (e, node) {mouseLeave(node); },
click: function(e, node) { showConnections(node); }
},
{ layout: $(go.LayeredDigraphLayout,
{columnSpacing: 10 }) },
graph(go.Shape, "RoundedRectangle", // surrounds everything
{name:"SHAPE", minSize: new go.Size(200, 100), parameter1: 10, fill: "#FFF", stroke: "#009BE1", cursor: "pointer"},
new go.Binding("stroke", "isHighlighted", function(h) { return h ? "#388E3C" : "#009BE1"; })
.ofObject(),
new go.Binding("fill", "isHighlighted", function(h) { return h ? "#E9F9D7" : "#FFF"; })
.ofObject(),
new go.Binding("fill", "isSelected", function(selected) {if (selected) return "#E9F9D7"; else return "#FFF";})
.ofObject(""),
new go.Binding("stroke", "isSelected", function(selected) {if (selected) return "#388E3C"; else return "#009BE1";})
.ofObject("")),
graph(go.Panel, "Vertical", // position header above the subgraph
{ defaultAlignment: go.Spot.Center },
graph(go.Panel, "Horizontal",
{ defaultAlignment: go.Spot.Top },
$("SubGraphExpanderButton"),
graph(go.TextBlock, // group title near top, next to button
{ font: "16px Sans-Serif", margin: new go.Margin(0, 5, 10, 5)},
new go.Binding("text", "key"))
),
graph(go.Placeholder, // represents area for all member parts
{name: "TEXT", padding: new go.Margin(5, 27, 0, 0), cursor: "pointer"},
new go.Binding("background", "isHighlighted", function(h) { return h ? "#E9F9D7" : "#FFF"; })
.ofObject(),
new go.Binding("background", "isSelected", function(selected) {if (selected) return "#E9F9D7"; else return "#FFF";})
.ofObject(""))
)
);
The screen shot below show the green hover background still visible on mouseLeave but the “SHAPE” element background correctly turns white as it should, also the links are not visible…
mouseEnter:
mouseLeave:
Thanks