Maintain selected node on top

Hi,
When i select a node or a group and i drag it over other nodes/groups, i would like the node to be on top of all nodes.
I tried to implement the mouseHold function with { node.zOrder += 100; } but the node does not overlap other nodes.
Any ideas ?

That should work if all of the other nodes and links have the appropriate value for Part.zOrder. What value are you assigning, and what values do the stationary parts have?

But the most common solution is not to use zOrder at all, but to bind Part.layerName. Many samples do this. For example, in the Org Chart Editor sample, https://gojs.net/latest/samples/orgChartEditor.html :

 // bind the Part.layerName to control the Node's layer depending on whether it isSelected
 new go.Binding("layerName", "isSelected", function(sel) { return sel ? "Foreground" : ""; }).ofObject(),

In this case the assumption is that you are not using the “Foreground” Layer for other purposes.

Please read https://gojs.net/latest/intro/layers.html.

Ok,
I will not use zOrder.
Yet, if i use layerName, when a group is selected, it does go “Foreground”, but when expended, its members are hidden behind it.
I guess i have to move “Foreground” all member parts, but then, there are many uses cases i have to cover, and also, it can be time consuming to run thru all member part when a group is selected.

If you search in this forum, you might find:


That event handler makes the Binding on layerName superfluous.