Modifying the z-order of a node


#1

Hello,

I was wondering if there’s a better way to change a
GoNode’s z-order within a GoDocument than removing it from the document
and re-adding it. Since this would blow away all the links, etc., I’m
hesitant to go down this path.

Thanks for the great component!


#2

You can just call GoLayer.Add with that node, which will just “move” the node to the other layer. This results in a GoDocument.Changed event with a hint that is GoLayer.ChangedObjectLayer.
If you Add an object to the layer it’s already in, it’s a no-op.


#3

So, as a possible solution, I could have a “top level” layer that
always only holds one object: the object that I want to be displayed
first. Selecting any other object would kick the former occupant out of
that layer, and put the new one in… that’ll work. Thanks!


#4

Take a look at how the Classier sample implements exactly what you propose.