Nevron Forum

Changing pan tool to operate on Shift + Left Mouse Click

https://www.nevron.com/Forum/Topic5469.aspx

By Kevin Harrison - Wednesday, August 10, 2011

Can you provide an example of how to change the Pan tool from operating on middle-mouse click to Shift + Left mouse click please? It was quite straightforward for Nevron Chart, but not so obvious to me at the moment for Diagram.

Thanks

Kevin

By Nevron Support - Thursday, August 11, 2011

Hi,

In your case you should create a custom tool that overrides the behavior of the NMouseWheelScrollAndZoomTool. The following is a sample implementation:

 

public class NCustomScrollAndZoomTool : NMouseWheelScrollAndZoomTool

{

      public NCustomScrollAndZoomTool()

      {

            this.Name = "Custom Scroll and Zoom Tool";

            StartMouseEvent = MouseEvent.LeftButtonDown;

      }

 

      public override bool CanActivate()

      {

            if (base.CanActivate() == false)

                  return false;

 

            return Control.ModifierKeys == Keys.Control;

      }

}

 

 

When you want to use the tool you should add it to the drawing view controller’s collection of tools and enable it:

 

NCustomScrollAndZoomTool customTool = new NCustomScrollAndZoomTool();

view.Controller.Tools.Add(customTool);

view.Controller.Tools.EnableTools(new string[] { customTool.Name });

 

 

If you want to disable the standard mouse scroll and zoom tool, you can do so by using the following line of code:

 

view.Controller.Tools.DisableTools(new string[] { NDWFR.ToolMouseWheelScrollAndZoom });