Moving a port without pressing the shift button

I use the PortShiftingTool.js to be able to move a port around a node.
In order to move a port, i must press the shit button.
Is there any way to change the behavior of moving a port to another button, for example just by pressing it (similar to like moving a node)?

Just change how it’s defined. Look at Note how PortShiftingTool.canStart checks for the InputEvent.shift modifier being true.

  var e = diagram.lastInput;
  if (!e.left || !e.shift) return false;

I modified the PortShiftingTool.js like that :
if (diagram.connectLinks && (!e.left || !e.shift)) return false;
And it worked fine.
Now, we are migrating our code to Angular (with Ido Dekkers) and i’m facing compilation error with this change, because connectLinks is not declared in diagram.
Any way to bypass this compilation error ?
By the way, although i have compilation error, still the code runs fine and i can shift port without pressing the shift key…

That error is correct – there is no “connectLinks” property on the Diagram class. There is no use of such a property in the PortShiftingTool either, so it must be something that you define in your app.

Ofcourse, but i have no other way to pass a flag to the code.
I need to pass some flag to canStart() function and the only way is thru diagram variable.
Any suggestions ?

Add the property to your copy of PortShiftingTool, and then you can set it by something like:

  const tool = myDiagram.toolManager.findTool(" of tool here...");
  if (tool !== null) (tool as PortShiftingTool).connectLinks = ...;

Oops – I see now that when I defined the PortShiftingTool I forgot to give it a new name in the constructor such as = "PortShifting";. I’ll fix that for 1.8.5 – I suggest that you fix it in your copy.