summaryrefslogtreecommitdiffstats
path: root/documentation
diff options
context:
space:
mode:
authorAdam Wagner <wbadam@users.noreply.github.com>2017-03-24 10:32:48 +0200
committerPekka Hyvönen <pekka@vaadin.com>2017-03-24 10:32:48 +0200
commitb32d7b0e45ddc9d7b720bc603ce5374404381a81 (patch)
treee139cd9301ecec46ce06d063109abefc70f36801 /documentation
parent6f1f83d4b95a45db03c5a74ad09b22541fb06e64 (diff)
downloadvaadin-framework-b32d7b0e45ddc9d7b720bc603ce5374404381a81.tar.gz
vaadin-framework-b32d7b0e45ddc9d7b720bc603ce5374404381a81.zip
Add API support for setting server side drag data (#8915)
* Add API support for setting server side drag data * Fix javadocs * Add server side drag data API to ASCII doc * Fix some javadocs and documentation details
Diffstat (limited to 'documentation')
-rw-r--r--documentation/advanced/advanced-dragndrop.asciidoc15
1 files changed, 15 insertions, 0 deletions
diff --git a/documentation/advanced/advanced-dragndrop.asciidoc b/documentation/advanced/advanced-dragndrop.asciidoc
index 36eaa27303..6e085633c1 100644
--- a/documentation/advanced/advanced-dragndrop.asciidoc
+++ b/documentation/advanced/advanced-dragndrop.asciidoc
@@ -50,6 +50,18 @@ dragSource.addDragEndListener(event ->
);
----
+It is possible to transfer any Object as server side data to the drop target if both the drag source and drop target are placed in the same UI. This data is available in the drop event via the `DropEvent.getDragData()` method.
+
+[source, java]
+----
+dragSource.addDragStartListener(event ->
+ dragSource.setDragData(myObject);
+);
+dragSource.addDragEndListener(event ->
+ dragSource.setDragData(null);
+};
+----
+
[NOTE]
====
The browsers allow the user to select and drag and drop text, which may cause some issues when trying to drag a component that has text. You can fix this by setting the following style rule to the drag source component to prevent dragging of the text instead of the whole component.
@@ -89,6 +101,9 @@ dropTarget.addDropListener(event -> {
// get possible transfer data
String message = event.getDataTransferText();
Notification.show("DropEvent with data transfer: "+ message);
+
+ // handle possible server side drag data, if the drag source was in the same UI
+ event.getDragData().ifPresent(data -> handleMyDragData((MyObject) data));
}
});
----