There is a bug in Java 6/7 on OSX where during Drag and Drop operations, it ignores the META (CMD) key. (Ctrl key works just fine on Windows, Ctrl key is also ignores on OSX) I REALLY need to have this working.
See: Java Drag and drop on OS X reports Move instead of Copy
I tried adding a KeyEventDispatcher listener to the KeyboardFocusManager, but that isn't called during a Drag operation.
Nor does the processKeyEvent() method of the parent JPanel ever get invoked.
So, is there any place where I can put a hook to detect META key presses?
On the DragGestureEvent you can get the modifiers. e.getTriggerEvent().getModifiersEx()
javadocs state:
Extended modifiers represent the state of all modal keys, such as ALT, CTRL, META, and the mouse buttons just after the event occurred.
This code worked for me on OSX:
public void dragGestureRecognized(DragGestureEvent e)
{
boolean isMetaDown = InputEvent.META_DOWN_MASK == (e.getTriggerEvent().getModifiersEx() & InputEvent.META_DOWN_MASK));
System.out.println("metaDown:"+isMetaDown);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With