How to cancel drag-and-drop with ESC key?


#1

Apologies if this is obvious but I couldn't find it anywhere.  How can I allow the user to press ESC to cancel a drag-and-drop operation (with DragAndDropContainer and DragAndDropTarget)?


#2

Coincidentally, I just hit this same requirement for tracktion, so will figure something out v. soon!


#3

Is there a way to achieve this behavior currently?


#4

It works already doesn’t it?
The only time I’ve not seen it work is with the standalone target for a plugin, where you need to have the file over the app window for Escape to work (on macOS 10.12 at least).


#5

Not sure about the file drag and drop, but we’re using DragAndDropContainer and DragAndDropTarget for re-ordering UI items and there’s no way to cancel a drag once you start it (without just dropping the item back in the same location or off to the side)


#6

Could you listen for an esc keypress and use that to toggle what the result of isInterestedInDragSource would be?