Modify control drag behaviour

Hi all,

Can anybody show me how to modify control + drag behaviour. I want drag and control drag both just move the object.


If you don’t want to allow objects to be copied in that GoView, you can set GoView.AllowCopy to false. However, this also disables GoView.EditCopy (aka Control-C). Setting GoDocument.AllowCopy to false has this effect for all GoViews displaying that document.

If you don't want to allow objects to be added in a GoView, you can set GoView.AllowInsert to false. However, this also disables drag-and-drop from another window, as well as GoView.EditPaste (aka Control-V).
If you still want ^X, ^C, and ^V to work, then you need to modify the GoView's GoToolDragging tool, to disable its ability to perform copies.
public class NotCopyingTool : GoToolDragging {
public NotCopyingTool(GoView v) : base(v) {}
public override bool MayBeCopying() { return false; }
During initialization, replace the standard dragging tool in your GoView by:
goView1.ReplaceMouseTool(typeof(GoToolDragging), new NotCopyingTool(goView1));

Thanks for the answer,

I follow your instructions. It turns out that the copy function is disable but I cannot move the object using Ctrl + Drag.

I want Ctrl + Drag = Drag = Just move object over a GoView

If you replace the standard GoToolDragging tool with the one I show above, both unmodified and modified (i.e. Ctrl) drag will only move the selection.

I checked again I did exactly as you told. The result is just the same like if we set AllowCopy = false !!

Get lost !!

In my GoView class, i also override EditCopy() and it do nothing.

Sorry, It’s working but not so nicely.

What really happened is:

You Press the Ctrl while dragging an object. Release the ctrl then the mouse, the object will move.

What I would like to have is : Press the Ctrl while dragging an object. Release the mouse then the object will move. It should be indentical to unmodified drag.

I’m sorry, but I am unable to reproduce the behavior that you see.

When I replace my GoView's dragging tool with the NotCopyingTool from above, dragging is always unaffected by whether the Control modifier is pressed, whether before, during or after the drag. Copying never happens -- moving always happens.
That happens whether GoView.DragsRealtime is true or false.

Hi, the below is my example for you:

using Northwoods.Go;
using System.Windows.Forms;
using System.Drawing;
using WindowsApplication8;

public class MinimalApp : Form
// constructor
public MinimalApp()
this.Text = “Minimal GoDiagram app”;
// create a Go view (a Control) and add to the form
GoView myView = new GoView();
myView.ReplaceMouseTool(typeof(GoToolDragging), new NotCopyDraggingTool(myView));

    myView.Bounds = this.ClientRectangle;

    // create two nodes for fun...
    GoBasicNode node1 = new GoBasicNode();
    // specify position, label and color
    node1.Location = new PointF(100, 100);
    node1.Text = "first";
    node1.Label.Editable = true;
    node1.Brush = new SolidBrush(Color.Blue);
    // add to the document, not to the view

    GoBasicNode node2 = new GoBasicNode();
    node2.Location = new PointF(200, 100);
    node2.Text = "second";
    node2.Label.Editable = true;
    node2.Brush = new SolidBrush(Color.Magenta);

public static void Main(string[] args) 
    Application.Run(new MinimalApp());


Here is the new dragging tool

using System;
using Northwoods.Go;

namespace WindowsApplication8

    /// <summary>
/// This class prevent Ctrl + Drag in GoView from copying object
/// </summary>

public class NotCopyDraggingTool : GoToolDragging
public NotCopyDraggingTool(GoView v) : base(v) {}

public override bool MayBeCopying() { return false; }


Ah, you must have an old version of GoDiagram. Add the following override to NotCopyDraggingTool:

public override bool MayBeMoving() { return true; }