When I set the Diagram.DragSelectingTool="{x:null}" ,I can drag the whole graph by mouseLeftButton.
But our costomers want to drag the whole graph by mouseRightButton?
How can I do this? :flushed:
Define a custom PanningTool that overrides CanStart not to care about it being a left mouse button event. Here’s the standard definition of PanningTool.CanStart:
public override bool CanStart() {
if (!base.CanStart()) return false;
Diagram diagram = this.Diagram;
if (diagram == null) return false;
if (!diagram.AllowScroll) return false;
// require left button & that it has moved far enough away from the mouse down point, so it isn't a click
if (!IsLeftButtonDown()) return false;
// don't include the following check when this tool is running modally
if (diagram.CurrentTool != this) {
// mouse needs to have moved from the mouse-down point
if (!IsBeyondDragSize()) return false;
}
return true;
}
So you can either remove the IsLeftButtonDown check or replace it with a IsRightButtonDown check.
Thx very much,it is very useful and I solved my problem by your method.
This method can be use to GoJS?
Yes, but the JavaScript is different:
PanningTool.prototype.canStart = function() {
if (!this.isEnabled) return false;
var diagram = this.diagram;
if (diagram === null) return false;
if (!diagram.allowHorizontalScroll && !diagram.allowVerticalScroll) return false;
// require left button & that it has moved far enough away from the mouse down point, so it isn't a click
if (!diagram.lastInput.left) return false;
// don't include the following check when this tool is running modally
if (diagram.currentTool !== this) {
// mouse needs to have moved from the mouse-down point
if (!this.isBeyondDragSize()) return false;
}
return true;
};