AbsolutePositionDropController - dragged widgets are not same as dropped widgets

54 views
Skip to first unread message

stagirus

unread,
Feb 3, 2012, 3:49:39 PM2/3/12
to gwt-dnd, mohan...@yahoo.com
I am using AbsolutePositionDropController. I ran into this challenge.

We drag & drop specific widget objects called EventContent that
extends Label. At the time of dropping these objects, we do some
processing on them. I tried to achieve this functionality by
overriding AbsolutePanel.add(Widget w, int left, int top) in a class
DataPanel extends AbsolutePanel. I passed the instances of these
objects (DataPanel) as drop targets to
AbsolutePositionDropController.

I was expecting that the Widget parameter to "add" method to be same
as the dragged objects (instances of EventContent). Unfortunately, it
is not. It is adding instances of wrapper widgets (SimplePanel). I
would naturally expect the dragged objects (widgets) to be same as the
dropped objects. I even tried to iterate through SimplePanel to locate
EventContent objects. No luck.

I am wondering if it was an oversight or a design issue.

Is it possible for the API to keep the dragged objects and dropped
objects to be the same instances? I mean the copies added to
AbsolutePanel should be same instance as the dropped widget(s).

Or, can anybody suggest some other options?

Thanks

Richard Rowell

unread,
Feb 7, 2012, 1:35:40 PM2/7/12
to gwt...@googlegroups.com
It sounds like you have proxies turned on?

> --
> You received this message because you are subscribed to the Google Groups "gwt-dnd" group.
> To post to this group, send email to gwt...@googlegroups.com.
> To unsubscribe from this group, send email to gwt-dnd+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/gwt-dnd?hl=en.
>

--
"An eye for eye only ends up making the whole world blind." -- Mohandas Gandhi

stagirus

unread,
Feb 7, 2012, 6:45:59 PM2/7/12
to gwt-dnd
That was a good suggestion. So I explicitly disabled proxies, as
follows:
dragController = new PickupDragController(boundaryPanel, false);
dragController.setBehaviorDragProxy(false);
dragController.setBehaviorDragStartSensitivity(2); // to enable
double click
dragController.setBehaviorScrollIntoView(true);
dragController.setBehaviorBoundaryPanelDrop(false);
dragController.setBehaviorConstrainedToBoundaryPanel(true);

It did not make any difference. It still sends "SimplePanel" for
widget param. What am I missing?

I call the following API to enable drag & drop:
Label content;
.....
dragController.makeDraggable(content)

Thanks
> > For more options, visit this group athttp://groups.google.com/group/gwt-dnd?hl=en.
>
> --
> "An eye for eye only ends up making the whole world blind." -- Mohandas Gandhi- Hide quoted text -
>
> - Show quoted text -

Fred Sauer

unread,
Feb 9, 2012, 5:18:02 PM2/9/12
to gwt...@googlegroups.com
Once you actually "drop" the object, the actual widget(s) should be added to the target. While dragging, there's a proxy or invisible container widget (which helps preserve layout of the original widget(s), and allows for multiple widgets to be added).

You can register a DragHandler to catch DragEnd events and so your processing there.

Also, you may be able to ignore the unexpected widgets in the add() method and just do nothing. When the drag completes (widgets are dropped and actually added), then your code can kick in.

stagirus

unread,
Feb 10, 2012, 11:28:59 AM2/10/12
to gwt-dnd
Thank you very much Fred. Your suggestion below worked. I appreciate
it.
Mohan
> f...@allen-sauer.com- Hide quoted text -
Reply all
Reply to author
Forward
0 new messages