ChiHungLam / gwtquery-plugins

Automatically exported from code.google.com/p/gwtquery-plugins
0 stars 0 forks source link

Missing MoveDroppableEvent #18

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
initial issue from http://code.google.com/p/gwtquery/issues/detail?id=96 moving 
here.

Hi yall,

thanks for great DnD library, I discovered it just recently, and have been 
using gwt-dnd so far. The reason I turned to gwtquery for support cell widgets 
in droppable module. My droppable is actually Flash application. That's right, 
DnD from GWT to Flash player :) it used to work pretty well with gwt-dnd.

The problem with gwtquery Droppable (and DroppableWidget wrapper): it has over, 
out, drop events, but no move (over droppable) event. We need that one to make 
calls to SWF and move something in it. It's kinda strange that this one is the 
only missing. I tried to use DroppableWidget.addDomHandler to add my own 
MouseMoveHandler, but the behavior is very strange. I'm receiving it like once 
in 50px movement when I'm dragging something. When dragging is NOT active, it 
works like expected. Makes me think there's something in gwtQuery.Droppable 
preventing this event to be fired (although not 100% working).

Also the way DroppableWidget works is a bit strange, it removes the original 
element from the DOM, so I have to add it again, which doesn't work well with 
UiBinder and such.

Original issue reported on code.google.com by julien.d...@gmail.com on 19 Aug 2011 at 4:12

GoogleCodeExporter commented 9 years ago
For your first problem :

You have to listen on the dragEvent on the draggable element...
So you can easily simulate what you call "move over droppable event" by 
implementing something like this :

public class MyHandler implements OverDroppableEventHandler, 
OutDroppableEventHandler, DragEventHandler{

  private HandlerRegistration dragHandlerRegistration;

  public void onOutDroppable(OutDroppableEvent event) {
    dragHandlerRegistration.removeHandler();
  }

  public void onOverDroppable(OverDroppableEvent event) {
    DraggableWidget<?> draggable = event.getDraggableWidget();
    // listen drag event when draggable is over the droppable
    dragHandlerRegistration = draggable.addDragHandler(this);
  }

  public void onDrag(DragEvent event) {
    // method call when the draggable is moving over the droppable

  }

}

//on your droppable Widget :
 DroppableWidget<Widget> droppable = ...
 MyHandler droppableHandler = new MyHandler();

droppable.addOutDroppableHandler(droppableHandler);
droppable.addOverDroppableHandler(droppableHandler);

Concerning the problem with the removal of the draggable element. Just tell to 
the draggable plugin to use a clone of the element for the drag operation by 
using the useCloneAsHelper() method :

dragableWidget.useCloneAsHelper();

Let's me know if the proposed solutions meet your requirements. 

Original comment by julien.d...@gmail.com on 19 Aug 2011 at 4:32

GoogleCodeExporter commented 9 years ago
Any update regarding my comment ?

Original comment by julien.d...@gmail.com on 24 Oct 2011 at 9:25