diff options
author | Adam Wagner <wbadam@users.noreply.github.com> | 2017-05-02 23:35:33 +0300 |
---|---|---|
committer | Pekka Hyvönen <pekka@vaadin.com> | 2017-05-02 23:35:33 +0300 |
commit | 61bada07475d77b88c112b19519ef88c58d5fe87 (patch) | |
tree | 404ebc148ecca96bf9d3d0ce59ab1d64b14eb592 | |
parent | a1c2b2f6764e51acdab16a8cd3234fba1d688005 (diff) | |
download | vaadin-framework-61bada07475d77b88c112b19519ef88c58d5fe87.tar.gz vaadin-framework-61bada07475d77b88c112b19519ef88c58d5fe87.zip |
Disable drag and drop for touch devices (#9216)
4 files changed, 23 insertions, 0 deletions
diff --git a/client/src/main/java/com/vaadin/client/connectors/grid/GridDragSourceConnector.java b/client/src/main/java/com/vaadin/client/connectors/grid/GridDragSourceConnector.java index 2caa82e84e..3f673bac01 100644 --- a/client/src/main/java/com/vaadin/client/connectors/grid/GridDragSourceConnector.java +++ b/client/src/main/java/com/vaadin/client/connectors/grid/GridDragSourceConnector.java @@ -27,6 +27,7 @@ import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.TableRowElement; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Window; +import com.vaadin.client.BrowserInfo; import com.vaadin.client.ServerConnector; import com.vaadin.client.WidgetUtil; import com.vaadin.client.extensions.DragSourceExtensionConnector; @@ -71,6 +72,11 @@ public class GridDragSourceConnector extends DragSourceExtensionConnector { protected void extend(ServerConnector target) { gridConnector = (GridConnector) target; + // Do not make elements draggable on touch devices + if (BrowserInfo.get().isTouchDevice()) { + return; + } + // Set newly added rows draggable getGridBody().setNewEscalatorRowCallback( rows -> rows.forEach(this::setDraggable)); diff --git a/client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java b/client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java index 946f37a9b1..8a26694bde 100644 --- a/client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java +++ b/client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java @@ -20,6 +20,7 @@ import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.Widget; +import com.vaadin.client.BrowserInfo; import com.vaadin.client.ComponentConnector; import com.vaadin.client.ServerConnector; import com.vaadin.client.annotations.OnStateChange; @@ -58,6 +59,11 @@ public class DragSourceExtensionConnector extends AbstractExtensionConnector { protected void extend(ServerConnector target) { dragSourceWidget = ((ComponentConnector) target).getWidget(); + // Do not make elements draggable on touch devices + if (BrowserInfo.get().isTouchDevice()) { + return; + } + setDraggable(getDraggableElement()); addDragListeners(getDraggableElement()); } diff --git a/client/src/main/java/com/vaadin/client/extensions/DropTargetExtensionConnector.java b/client/src/main/java/com/vaadin/client/extensions/DropTargetExtensionConnector.java index 9686ea796e..e3fbeabab4 100644 --- a/client/src/main/java/com/vaadin/client/extensions/DropTargetExtensionConnector.java +++ b/client/src/main/java/com/vaadin/client/extensions/DropTargetExtensionConnector.java @@ -19,6 +19,7 @@ import com.google.gwt.dom.client.DataTransfer; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.user.client.ui.Widget; +import com.vaadin.client.BrowserInfo; import com.vaadin.client.ComponentConnector; import com.vaadin.client.ServerConnector; import com.vaadin.event.dnd.DropTargetExtension; @@ -78,6 +79,11 @@ public class DropTargetExtensionConnector extends AbstractExtensionConnector { protected void extend(ServerConnector target) { dropTargetWidget = ((ComponentConnector) target).getWidget(); + // Do not make elements drop target on touch devices + if (BrowserInfo.get().isTouchDevice()) { + return; + } + addDropListeners(getDropTargetElement()); } diff --git a/documentation/advanced/advanced-dragndrop.asciidoc b/documentation/advanced/advanced-dragndrop.asciidoc index 1b424ed167..8516e9be6f 100644 --- a/documentation/advanced/advanced-dragndrop.asciidoc +++ b/documentation/advanced/advanced-dragndrop.asciidoc @@ -17,6 +17,11 @@ the other location is a common way to move, copy, or associate objects. For example, most operating systems allow dragging and dropping files between folders or dragging a document on a program to open it. Framework version 8.1 adds support for https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API[HTML5 drag and drop] features. This makes it possible to set components as drag sources that user can drag and drop, or to set them as drop targets to drop things on. +[NOTE] +==== +Note that the HTML5 drag and drop feature is not supported on touch devices. +==== + == Drag Source Any component can be made a drag source that has textual data that is transferred when it is dragged and dropped. |