summaryrefslogtreecommitdiffstats
path: root/documentation/advanced/advanced-dragndrop.asciidoc
diff options
context:
space:
mode:
Diffstat (limited to 'documentation/advanced/advanced-dragndrop.asciidoc')
-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));
}
});
----