RFR: 8227371: Drag&Drop while holding the CMD key does not work on macOS

Pankaj Bansal pbansal at openjdk.java.net
Tue Nov 9 09:27:40 UTC 2021


On Fri, 22 Oct 2021 17:32:10 GMT, Martin Fox <duke at openjdk.java.net> wrote:

> During a drag-and-drop operation on the Mac the Command key will filter out every drag source operation except `NSDragOperationGeneric` (this behavior is provided by the OS). JavaFX drag sources only set the Move, Copy, and Link drag operation bits so the Command key reduces the set of available operations to nothing.
> 
> This PR changes nothing about how JavaFX behaves when the dnd operation involves an external application. As a drag source the same set of operations will be broadcast and as a drag destination the operations will be interpreted as they have always been.
> 
> For internal dnd within the JavaFX app `NSDragOperationMove` and `NSDragOperationGeneric` will both be set if the drag source specifies `TransferMode.MOVE`. On the other end a drag destination will interpret `NSDragOperationGeneric` and `NSDragOperationMove` as synonyms.
> 
> As part of this PR it was necessary to verify that `NSDragOperationGeneric` was not already being used during an internal drag operation.  There's a clause in `mapJavaMaskToNsOperation:` which translates `com_sun_glass_ui_Clipboard_ACTION_ANY` to `NSDragOperationEvery` and this includes the Generic bit. I believe this is a red herring, the Java dnd code converts `TransferMode.ANY` to a bitwise-OR of COPY, MOVE, and REFERENCE so `com_sun_glass_ui_Clipboard_ACTION_ANY` will never be passed down to the platform level.

Looks good to me. I tested the testcase attached in JBS on macOS BigSur and I can see the move operation is selected if cmd key is pressed after the fix.

-------------

Marked as reviewed by pbansal (Committer).

PR: https://git.openjdk.java.net/jfx/pull/651


More information about the openjfx-dev mailing list