Skip to content
This repository has been archived by the owner on Dec 8, 2017. It is now read-only.

Miscalculation of DragContext's mouseX and mouseY when the drag handle is not the draggable. #159

Open
GoogleCodeExporter opened this issue Mar 13, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

Does the issue occur in "quirks mode", "standards mode" or both? If you
don't know, does your HTML page contains a DOCTYPE declaration?
standards mode

What version of GWT are you using? 1.4.60? 2.0.4? Other?
2.3.0

What version of the gwt-dnd jar file or library file are you using?
3.1.1

What operating system(s) are you using? Windows? Linux? Mac?
Windows

Does the issue occur in web mode, development mode (formerly "hosted
mode"), both or don't know?
At least dev mode.

What browser(s) do you use? Chrome, Firefox, IE, Safari, other?

What is the browser version (if you know) from Help->About?

What steps will reproduce the problem? Please attach sample code if you can.
class MouseDragHandler :

  public void onMouseDown(MouseDownEvent event) {
    ...
    Widget sender = (Widget) event.getSource();
    int x = event.getX();
    int y = event.getY();
    ...
    // mouse down (not first mouse move) determines draggable widget
    mouseDownWidget = sender;
    context.draggable = dragHandleMap.get(mouseDownWidget).getDragable();
    ... 
    mouseDownOffsetX = x;
    mouseDownOffsetY = y;
    WidgetLocation loc1 = new WidgetLocation(mouseDownWidget, null);
    if (mouseDownWidget != context.draggable) {
      WidgetLocation loc2 = new WidgetLocation(context.draggable, null);
      mouseDownOffsetX += loc1.getLeft() - loc2.getLeft();
      mouseDownOffsetY += loc1.getTop() - loc2.getTop();
    }
    ...

mouseDownOffsetX and mouseDownOffsetY are the mouse offset coordinates from the 
draggable's (top, left).

And :
  public void onMouseMove(MouseMoveEvent event) {
    ...
    if (dragging == ACTIVELY_DRAGGING || dragging == DRAGGING_NO_MOVEMENT_YET) {
        ...
    } else {
      if (mouseDownWidget != null) {
        ...
          // set context.mouseX/Y before startDragging() is called
          Location location = new WidgetLocation(mouseDownWidget, null);
          context.mouseX = mouseDownOffsetX + location.getLeft();
          context.mouseY = mouseDownOffsetY + location.getTop();

          startDragging();
          ...

When startDragging() is called, context.mouseX and mouseY are computed by 
adding the draggable offset to the drag handle's location.


For the same reason, at the end of onMouseDown(), the computing of 
mouseDownPageOffsetX ( = mouseDownOffsetX + loc1.getLeft()) and 
mouseDownPageOffsetY don't seems to be correct.


What is the expected output? What do you see instead?


Do you have a workaround?
In onMouseMove(), maybe the location used should be the context.draggable's one 
:
          Location location = new WidgetLocation(context.draggable, null);


Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 6 Apr 2012 at 2:14

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant