I'm trying to implement a fairly basic drag and drop feature with an
image and I keep hitting a problem which is probably simple to fix
(just started with GWT this past week).
I can make an image draggable by adding a mouse listener, and then
using the functions to reposition it -- currently, it looks like this
(almost directly from the DialogBox class).
public void onMouseDown(Widget sender, int x, int y){
dragging = true;
DOM.setCapture(panel.getElement());
dragStartX = x;
dragStartY = y;
//Window.alert(Integer.toString(x));
}
public void onMouseUp(Widget sender, int x, int y){
dragging = false;
DOM.releaseCapture(panel.getElement());
}
public void onMouseMove(Widget sender, int x, int y){
if (dragging) {
int absX = x + getAbsoluteLeft();
int absY = y + getAbsoluteTop();
setPopupPosition(absX - dragStartX, absY - dragStartY);
}
}
The problem I'm having is that when I drag the image in firefox, it
starts to move at first, but then it thinks I'm trying to drag the
image off the screen (to save it to the desktop, for example) and I
get the little firefox image-dragging icon, and my actual image
doesn't move. Any ideas on how to fix this?
Thanks in advance,
Justin
DOM.eventPreventDefault(event);
DOM.eventCancelBubble(event, true);
Basically FF has its own behavior when trying to drag an image, and
you'll have to tell it to knock that off.
-jason
What not using existing project to implement the functionalities you
want over it ??
http://www.ongwt.com/post/2007/02/13/gwt-dnd-:Drag-and-Drop-for-GWT
Regards.
Luciano
---
http://www.gwtwindowmanager.org
Cheers,
Justin