Panning on right mouse drag

My application uses left drag for selecting a region, and I’d like to use right drag for panning the view. What’s the best way to make this work? I can’t seem to get the GoPanningTool to respond to right drags.

That’s “right”. GoToolPanning doesn’t work with the right mouse button.
From your description, it sounds like you want a modeless panning tool. And you want something different from the standard panning behavior when you click the middle mouse button.
But you can override GoToolPanning.CanStart in order to check for the right mouse button instead of the left one, as follows:
public class RightMousePanningTool : GoToolPanning {
public RightMousePanningTool(GoView view) : base(view) {
this.AutoPan = false;
this.Modal = false;
}
public override bool CanStart() {
GoInputEventArgs e = this.LastInput;
if (e.Alt || e.Control || e.Shift) return false;
if (!e.IsContextButton) return false; // normally checks for MouseButtons.Left
return true;
}
public override void DoMouseUp() {
if (!IsBeyondDragSize()) { // mouse didn’t move much – handle as a context click
GoToolContext ctool = this.View.FindMouseTool(typeof(GoToolContext), true) as GoToolContext;
if (ctool != null) {
this.View.Tool = ctool; // start context click tool
ctool.DoMouseUp(); // handle normal context click
return;
}
}
base.DoMouseUp();
StopTool();
}
}
Install your modeless tool:
myView.MouseDownTools.Insert(0, new RightMousePanningTool(myView));
This places your tool before GoToolContext, because GoToolContext normally handles all operations with the context (i.e. right) button.
I first tried the above class without the DoMouseUp override. It didn’t work, because I needed to put this tool before GoToolContext.
It did work when the tool came before GoToolContext, but then regular context-click behavior didn’t work. So I added the override of DoMouseUp, as shown above, to explicitly invoke the context-click-handling tool.