Saturday, February 25, 2012

Re: Pass data through event.setData() in 2.4 Drag and Drop

Ludovit:

Thanks for responding. I posted the code this way just to show the
problem. I have the drop target set up and is getting null from
getData().

Colin

On Feb 25, 5:15 am, Martones <ludovit.marton...@gmail.com> wrote:
> Hi Colin, maybe this document could help you :http://static.googleusercontent.com/external_content/untrusted_dlcp/w...
> look at theDNDsection.
>
> The data you are passing is to be received by the "drop target", not
> the widget you are dragging.
>
> In brief you need to:
> - create draggable widget : setDraggable + addDragStartHandler
> - create drop target : addDragOverHandler, addDropHandler
>
> Hope this helps ;)
>
> Ludovit
>
> On 11 fév, 15:24, colin <colinzhao...@yahoo.com> wrote:
>
>
>
>
>
>
>
> > Has anyone used newDragandDropfeature with 2.4?  I have it work
> > all fine except the string data set on the event in DragStartHandler
> > is not passed to the event in other handlers.  getData always returns
> > null.
>
> >                 navLabel.getElement().setDraggable(Element.DRAGGABLE_TRUE);
> >                 navLabel.addDragStartHandler(new DragStartHandler() {
>
> >                         @Override
> >                         public void onDragStart(DragStartEvent event) {
> >                                 event.setData("text", navContent.getId()); //I want to pass the
> > obejct id
>
> >                                 navLabel.addStyleName("s-ContentTOCItem");
> >                                 event.getDataTransfer().setDragImage(navLabel.getElement(),
> >                                                 10, 10);
> >                                 navLabel.removeStyleName("s-ContentTOCItem");
> >                                 String text = event.getData("text"); //Since I am getting the null
> > data in otherDnDevent, I want to test it here
> >                                 System.out.println("Dragtext: "+text); //text is null. Data is
> > not stored.
>
> >                         }
>
> >                 });

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

No comments:

Post a Comment