Friday, July 27, 2012

Re: DragOverEvent issue

This is the expected behavior (a security measure): http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dndevents ("protected mode" changes the behavior of getData to return early; basically you can know the type of data that's being dragged, but not the actual data).
GWT does not expose the "types" property (JsArrayString), and I don't know how well it's supported across browsers…

On Friday, July 27, 2012 3:52:29 PM UTC+2, Thomas Lefort wrote:
I have an issue with DragOverEvent.

At drag start I set my event data to a certain value, as follows:

panel.addDomHandler(new DragStartHandler() {
@Override
public void onDragStart(DragStartEvent event) {
event.setData("text", ResourceWidget.this.resource.getClass().getName());
event.getDataTransfer().setDragImage(panel.getElement(), 10, 10);
                                                ... some more code
}
}, DragStartEvent.getType());

On hover and on drop I test the value of the event data as follows:

campaignMap.addDomHandler(new DragOverHandler() {
@Override
public void onDragOver(DragOverEvent event) {
   event.preventDefault();
   if(event.getData("text") != null) {
                                              (1)  ... some more code
   }
}
}, DragOverEvent.getType());
campaignMap.addDomHandler(new DropHandler() {
@Override
public void onDrop(DropEvent event) {
   event.preventDefault();
   if(event.getData("text") != null) {
                                              (2)  ... some more code
   }
}
}, DropEvent.getType());
The issue is that with the hover event I get always null for my data value whilst for the drop I get the right value, ie (1) is never run and (2) runs.

In the end the drag and drop works, but I would also like to make use of the drag event to display some information based on the value of the data.

Any idea? is this a bug?

Thanks,

Thomas

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/44K8NpQm5aIJ.
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