Providing a label to all selected entities, after leaving control key

Hello Support,

To create a CANVAS, I am using GOJS in my project. So now I am facing a problem, suppose I have dragged 10 shapes, now I want to provide a label to 4 shapes from dragged shapes, so how to trigger an event(function) after leaving control(ctrl) key, and all selected shape can be iterated and I can provide a label to them. Please suggest.

Thanks
Shivam Varshney

I’m not sure I understand exactly what you want to do.

But I think you want to implement a “SelectionMoved” and/or “SelectionCopied” and/or “ExternalObjectsDropped” DiagramEvent listener that iterates over the moved/copied/externally-drag-and-dropped Parts and modifies them.

Presumably your node template has a binding on some TextBlock in your node, whose source is some data property. So your loop could just call Model.set (a.k.a. Model.setDataProperty) on the node.data and the desired property name and the desired new property value. And the node label will get updated automatically.

Hi,

Thanks for replying me.
Suppose I have dragged some shapes and created a canvas. Then I select some shapes by pressing ctrl key and hold it. So I want to know, is there any event which can be trigger when I un-hold(Remove the finger from ctrl key) the ctrl key?
I have attached a file where I have created some shapes, and then by holding ctrl key, I have selected some shapes.

What you literally ask for you can get by overriding ToolManager.doKeyUp:

    myDiagram.toolManager.doKeyUp = function() {
      var e = this.diagram.lastInput;
      console.log(e.key.toString() + " key up at: " + e.documentPoint.toString())
      go.ToolManager.prototype.doKeyUp.call(this);
    }

But I’m not convinced that this is really what you want to do. What do you want the user to accomplish?