JDK-5031138 : When doing a drag and drop, the drop event does not have the modifiers set.
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2004-04-13
  • Updated: 2018-09-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
Name: gm110360			Date: 04/13/2004


FULL PRODUCT VERSION :
java version "1.4.2_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]

A DESCRIPTION OF THE PROBLEM :
When doing a drag and drop, the drop event does not have the modifiers set.

It is not possible to tell which mouse button the user is holding down when a drag and drop is done.  Holding down the left button says button == 0, holding down the right mouse button still says button == 0.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run code
drag onto the text field with the left mouse button held down
observe in the console button == 0
drag onto the text field with the right mouse button held down
observe in the console button == 0

(also note getModifiersEx() == 0 in both cases)

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
the button results to be different in both cases
ACTUAL -
the button results are the same

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.datatransfer.*;
import javax.swing.*;

public class Test {
  public static void main(String[] args) {
    JFrame frame = new JFrame();
    JTextField textField = new JTextField();
    textField.setTransferHandler(new TransferHandler() {
      public boolean canImport(JComponent aComponent, DataFlavor[] aFlavorArray) {
        System.out.println(EventQueue.getCurrentEvent());
        return super.canImport(aComponent, aFlavorArray);
      }
    });
    frame.getContentPane().add(textField);
    frame.setSize(200, 200);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
  }
}
---------- END SOURCE ----------
(Incident Review ID: 250057) 
======================================================================

Comments
EVALUATION Currently there is no API for getting pressed mouse buttons on the drop in the end of a DnD operation. We need to instrument java.awt.dnd.DropTargetDropEvent with a new method that provides such information. Is it the only problem with showing a popup menu on a drop? Has the submitter successfully implemented showing a popup menu on a drop regardless of the mouse buttons state? On what platforms their implementation works?
08-09-2005

EVALUATION Name: agR10216 Date: 04/14/2004 During DnD operation ordinary mouse events are not delivered. This subject is touched upon in the section 3.0.1 of the DnD spec (http://java.sun.com/j2se/1.5.0/docs/guide/dragndrop/spec/dnd1.html): "Due to limitations of particular underlying platform Drag and Drop and Window System implementations, the interaction of a Drag operation, and the event delivery semantics to AWT Components is platform dependent. Therefore during a drag operation a DragSource may process platform Window System Events pertaining to that drag to the exclusion of normal event processing." and in the javadoc for java.awt.event.MouseEvent: "Due to platform-dependent Drag&Drop implementations, MOUSE_DRAGGED events may not be delivered during a native Drag&Drop operation." What you see in the console when running the test are implementation- dependent events that users of the DnD API shouldn't rely on and exploit in any way. To be notified about events pertinent to a DnD operation, one should use java.awt.dnd.DragSourceListener and DropTargetListener. Note that Swing wrappers these and other AWT DnD classes by means of javax.swing.TransferHandler. ###@###.### 2004-04-14 ======================================================================
14-04-2004