Duplicate shape creation

While dragging shape with control pressed, then i get a copy of the object. In this link it is stated “If the user holds down the Control key (Option key on Mac), this tool will make a copy of the parts being dragged, for those parts for which Part.canCopy is true.” so i tried copyable property to false, while it did prevent copying while dragging, but it also prevented the normal copy and paste of object. So how do i prevent the ctrl+ drag = paste functionality.

Set DraggingTool | GoJS API to false.

In your Diagram initialization:

    $(go.Diagram, . . .,
      { . . .,
        "draggingTool.isCopyEnabled": false

Hi Walter,

This will disable copy for whole diagram. I am trying to disable copy for only one shape.


So you have a particular Part for which you want to allow CommandHandler copy-and-paste and DraggingTool move, but for which you do not want to allow DraggingTool copy, yet you want to allow DraggingTool copy on all other Parts (as well as move, of course)?

It isn’t clear to me that that there is any easy way to achieve that. I’d have to see if there are any DraggingTool methods that could be overridden.

Are you sure that there aren’t any other possibilities in your requirements?

Ha – try this custom Node class:

  function MaybeCopyableNode() {
  go.Diagram.inherit(MaybeCopyableNode, go.Node);

  MaybeCopyableNode.prototype.canCopy = function() {
    var diagram = this.diagram;
    if (diagram !== null && diagram.currentTool instanceof go.DraggingTool && this.data.text === "Beta") return false;
    return go.Node.prototype.canCopy.call(this);

Of course you’ll need to customize the Part.canCopy override to return false when you want.

I don’t know if this would work when dragging from a different Diagram, such as a Palette. But it isn’t clear to me that that would matter for you.

That was more than what was needed… Thanks walter

Really? I think it was only just enough to implement what I thought you needed. Perhaps I misunderstood your requirements.