MD
unread,Feb 20, 2012, 10:04:17 PM2/20/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to gwt-dnd
Hi,
I want to clarify the way to override newDragProxy.
Here's my case. I need a palette whose each item is dragged on a
canvas, moved around, and resized. It is just a plain tool palette of
Label, TextBox, TextArea, and so on.
I made it with PaletteWidget and WindowPanel in examples, and which
works perfect. But some are not clear to me.
Here's the code:
@Override
protected Widget newDragProxy(DragContext context) {
AbsolutePanel container = new AbsolutePanel(); // 1
Widget proxy = null;
Widget widget = context.draggable;
widget.removeStyleName("dragdrop-dragging"); // 2
if(!(widget instanceof PaletteWidget)){
throw new IllegalStateException("Unhandled Widget class " +
widget.getClass().getName());
}
widget = ((PaletteWidget) widget).getWidget();
// Create proxy object(e.g. TextBox)
proxy = new WindowPanel(this.windowController, new HTML(), textBox,
false);
proxy.addStyleName("dragdrop-dragging"); // 2
container.add(proxy); // 1
// to make proxy work
context.draggable = proxy; // 3
context.selectedWidgets.clear(); // 4
context.selectedWidgets.add(proxy); // 4
return container; // 1
}
Some look required like 1 above by referencing to
PickupDragController#dragStart and #dragEnd.
But what about 2, 3, and 4? It doesn't work correctly without.
Without 2, a dragged palette object becomes transparent while a
dragged WindowPanel object stays opaque.
Without 3, a dragged WindowPanel object will not correctly placed.
Without 4, a dragged WindowPanel object disappears after dragEnds.
So could you clarify if I override correctly and do something wrong?
Or it is very helpful if its contract, the way to override, is clearly
stated.
Thanks!