Z Order/Layers

Walter,

I’m on top of most of the API now, but I have a few niggles that would be nice to sort out.

  1. Layers/Z-Order

When dragging nodes around the canvas they appear above some items and below others. This is obviously zorder issues.

Is there a simple method to bring all selected items to the front before they are dragged - or - could they be moved to another layer during the drag?

  1. Drag from Pallete.

When dropping an item on the diagram from the pallete - the diagram does not have focus. If you where to drop an item and immediately press undo -nothing happens.

  1. nodes added to group.

Without adding a memberAdded/memberRemoved event to a Group node - is there anywhere in the framework that I can extend/subclass to handle the event more progmatically. All of my parts on the diagram are Groups - and I would much prefer to override a base class (which is why I was trying to subclass a Group).

Regards,

Gary.

  1. Yes, it is easy to change the layer of the selected parts. This is demonstrated in the Org Chart Editor sample:

// 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()
You could also implement this using a Part.selectionChanged function, if you are not using data binding.

  1. I don’t think it’s a good idea to automatically change focus from the Palette to the target Diagram upon an external drag-and-drop. But you could change focus yourself in an “ExternalObjectsDropped” DiagramEvent handler, if you were able to call Diagram.focus(). Alas that method isn’t public yet, but we will make it so for the next release (1.0.5).

  2. Can you set Part.containingGroupChanged on each of the Nodes that you define? Or am I misunderstanding what you want to do?

Thanks for the quick reply.

  1. If I change that Layer of a Group - should all the items contained within the group also move - it does not appear to.

  2. Not a problem - I’ll wait for you new method.

  3. I’ve sorted this. I had confused myself.

In the GoSilverlight- I was able to change the alpha channel for the components begin dragged. It would be useful if I could change to opacity. Is this something that can be done out of the box?

G.

  1. No, each Part’s layer is independent of each other. This allows Group members to be in different layers.

You can replace the binding of “layerName” to “isSelected” with a Part.selectionChanged function that sets Part.layerName of each Part in the Set returned by Group.findSubGraphParts().

Regarding opacity, no, that is a feature that we postponed implementing. It is not something that would come for “free” with canvas-based drawing. You can achieve that effect by changing the Shape.fill, Shape.stroke, TextBlock.stroke, GraphObject.background, et al.

Thank you for the inspiration.

I’ve now implemented functionality that will change the opacity of a dragged set of nodes.

I’ve overriden the DraggingTool.

G.

Walter,

when I say working …

Could you please explain some of the innerworking of GoJS, from what I understand …

the Pallete has it’s own draggingTool. When a part is dragged into the Diagram, a new “temp” part is created within the Diagram model - and control is proxied through the DraggingTool implemented in the Diagram.

To acomplish my requirment (ie. to make the dragged nodes transparent) - I simply reduce the alpha of each of the fill and stroke properties contained in the dragged parts. This works perfectly but for parts dragged from the pallete there is one side-effect.

If I “undo” the part dropped from the pallete - it does not remove it from the canvas.

In addition, if I move the part that was originally dragged from the pallete - then I get a load of Log messages claiming that the move is not done within a transaction.

My thought is that it’s somehow due to the proxy between the pallete and diagram dragging tool. Perhaps the transaction is started on the pallete - but when I amend some properties from within the diagram dragging tool - then the transaction is cancelled.

When do you execute the code to change the alpha of the brushes used by your Shapes?

We’ll investigate how to do what you want.

Sorted it.

When dragging from the pallete - I was changing the layerName of the dragged parts.

I’ve now got transparency working for parts dragged within the canvas and from the pallete.

Undo also works.

Super.

Gary.