Friday, July 27, 2012

Re: DragOverEvent issue

OK, but you mentioned that it might not be supported by all browsers? I might give it a try but it sounds like I could be going into murky waters.


On 27 July 2012 17:37, Thomas Broyer <t.broyer@gmail.com> wrote:
JSNI to access the "types" property of the DataTransfer object?
(along with using specific types to distinguish different types of data, rather than inferring from the content for a single type)


On Friday, July 27, 2012 5:27:22 PM UTC+2, Thomas Lefort wrote:
OK, thanks for the fast answer Thomas. I guess it's not good news though. Any recommendations on how to distinguish between objects being dragged over a widget using the dragovervent?


On Friday, 27 July 2012 15:52:29 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/-/JrFKzyv0NrAJ.

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.

--
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