Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8013593

[macosx] Mouse location on the Y axis is misreported during drag and drop

XMLWordPrintable

      FULL PRODUCT VERSION :
      1.7.0_10

      ADDITIONAL OS VERSION INFORMATION :
      OS X 10.8.2

      A DESCRIPTION OF THE PROBLEM :
      On OS X and JDK 7, the following APIs misreport the mouse's location on the Y axis while a drag and drop operation is in progress:

      MouseInfo.getPointerInfo().getLocation()
      DragSourceDragEvent.getLocation()

      The degree of error in the reported mouse location is related to the height of the drag image assigned to the TransferHandler that initiates the drag (via TransferHandler.setDragImage). If the TransferHandler has a null drag image then the reported mouse location is still off by some pixels and it seems impossible to know by how many.

      This bug exists on OS X + JDK7 only. It does not occur on Windows 7 + JDK 7, nor does it occur on OS X + JDK6.

      REGRESSION. Last worked in version 6u31

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Initiate a drag and drop operation on Mac OS X and check the values of

      MouseInfo.getPointerInfo().getLocation().y

      before, during, and after the drag. Notice that as soon as the drag begins the reported y location changes.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The value of MouseInfo.getPointerInfo().getLocation().y will be consistent with the mouse's true on screen location during the drag and drop operation.
      ACTUAL -
      The value of MouseInfo.getPointerInfo().getLocation().y is misreported while a drag and drop operation is in progress.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      It appears that the reported value of MouseInfo.getPointerInfo().getLocation().y is off by two times the height of the drag image while the drag and drop operation is in progress.

        To work around the problem, always assign a drag image to the TransferHandler. If you have no drag image to use (and would normally set a null drag image), create a transparent BufferedImage and use it as the drag image instead. This way the drag image will have a known height in all cases.

      Then, when the application is running on OS X, all classes that call MouseInfo.getPointerInfo().getLocation().y while a drag and drop operation is progress should subtract 2 * dragImage.getHeight() from the value of MouseInfo.getPointerInfo().getLocation().y to get the mouse's true location on the screen.

      This workaround applies to other API calls as well, such as DragSourceDragEvent.getLocation().y

            pchelko Petr Pchelko (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: