DragTool inconsistent duplicate keyboard shortcut

So according to macOS User Guide the equivalent of Option is Alt on windows keyboard.

Also the DraggingTool documentation says:

During the drag if the user holds down the Control/Option key this tool makes a copy of the draggedParts and proceeds to drag it around. (It only copies the Diagram.selection, not the whole effective collection, if copiesEffectiveCollection is false.) The collection of copied parts is held by copiedParts.

I tried this on both windows and mac on the Basic Example page:

  • On windows Control drag duplicates the selection
  • On mac Option drag duplicates the selection

Why is this inconsistent and how can I make both only duplicate with Option (mac)/ Alt (windows)?

That’s weird, it should be Control on Windows and Command on mac, to make it equivalent to CTRL + C and Command + C as the copy invocation. This seems like a documentation bug on our part. But note that the correct combination is not what you are expecting, so if we fix it, it may still not work as you want.

Meanwhile, if you want to have DraggingTool consider different keys during mayCopy to use whatever you prefer, you can override it. Here’s the default implementation:

// in production you might want window.navigator or someRootYouTest.navigator depending on platforms targeted
const isMac =
  navigator !== undefined &&
  navigator.platform !== undefined &&
  navigator.platform.match(/(iPhone|iPod|iPad|Mac)/i) !== null;
  
myDiagram.toolManager.draggingTool.mayCopy = function () {
  if (!this.isCopyEnabled) return false;
  const diagram = this.diagram;
  if (
    diagram.isReadOnly ||
    diagram.isModelReadOnly ||
    !diagram.allowInsert ||
    !diagram.allowCopy
  )
    return false;
  if (!(isMac ? diagram.lastInput.alt : diagram.lastInput.control)) return false;
  const it = diagram.selection.iterator;
  while (it.next()) {
    const part = it.value;
    if (part.canCopy()) return true;
  }
  if (this.draggedLink !== null && this.dragsLink && this.draggedLink.canCopy())
    return true;
  return false;
};

Thanks for the quick response. Most of the apps on windows make a copy of the selection with Alt + drag. Photoshop and Figma to name a few. So Control + drag seems really an odd choice to me.

That snippet should do the trick for us though.

Oh that’s true re: Photoshop. But in the Windows file explorer windows, CTRL+Dragging a file is the combination to make a copy of the file. So we are (apparently) being consistent with each OS’s respective file explorer, and that must have been what we used to decide the pattern.

So we don’t intend to change this, though I agree its a bit weird as it is.