Friday, December 30, 2011

How to handle the drag & drop of a hyperlink in GWT

Hi all,

I want to handle the drag & drop of hyperlinks in my app. The
hyperlink could be from any where, therefore I cannot make it
setDragable(true) and setData("link", "the URL") to mark it.

A very similar scenario would be Google Image search by image, where
you can drag & drop a link of image to the search box.

The sample code,

Label lblDropLink = new Label("Drop a link here");
lblDropLink.addDragOverHandler(new DragOverHandler() {

@Override
public void onDragOver(DragOverEvent event) {
lblDropLink.setText("Drop here to add the link.");
lblDropLink.setStyleName("dragOverFade");
}
});
lblDropLink.addDropHandler(new DropHandler() {

@Override
public void onDrop(DropEvent event) {
event.preventDefault();

// QUESTION: how to get the link, and even its text?
}
});

Thanks!

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