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() {

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

public void onDrop(DropEvent event) {

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


You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment