Drop effect on DataTransfer object.
This patch updates the data transfer object to implements the
drop effect.
For the dragenter and dragover events, the dropEffect will be
initialized based on what action the user is requesting. How this
is determined is platform specific, but typically the user can press
modifier keys to adjust which action is desired. Within an event
handler for the dragenter and dragover events, the dropEffect should
be modified if the action the user is requesting is not the one
that is desired.
For dragstart, drag, and dragleave events, the dropEffect is
initialized to "none". Any value assigned to the dropEffect will be
set, but the value isn't used for anything.
For the drop and dragend events, the dropEffect will be initialized
to the action that was desired, which will be the value that the
dropEffect had after the last dragenter or dragover event.
Change-Id: I09e75c35357d081c40f2827dd7b2e995b08f1a93
diff --git a/user/src/com/google/gwt/dom/client/DataTransfer.java b/user/src/com/google/gwt/dom/client/DataTransfer.java
index b7414a3..d9228b4 100644
--- a/user/src/com/google/gwt/dom/client/DataTransfer.java
+++ b/user/src/com/google/gwt/dom/client/DataTransfer.java
@@ -17,6 +17,9 @@
import com.google.gwt.core.client.JavaScriptObject;
+import java.util.Locale;
+
+
/**
* Class representing DataTransfer interface.
*
@@ -114,4 +117,52 @@
this.setDragImage(element, x, y);
}
}-*/;
+
+ /**
+ * Specify the drop effect to use on dragenter or dragover events.
+ *
+ * @param dropEffect the drop effect to display.
+ */
+ public final void setDropEffect(DropEffect dropEffect) {
+ this.setDropEffect(dropEffect.name().toLowerCase(Locale.ROOT));
+ }
+
+ /**
+ * Specify the drop effect to use on dragenter or dragover events.
+ *
+ * @param dropEffect the drop effect to display.
+ */
+ private native void setDropEffect(String dropEffect) /*-{
+ if (this.dropEffect) {
+ this.dropEffect = dropEffect;
+ }
+ }-*/;
+
+ /**
+ * Used to specify the drop effect to use on dragenter or dragover events.
+ *
+ * For dragstart, drag, and dragleave events, the dropEffect is initialized to "none".
+ * Any value assigned to the dropEffect will be set, but the value isn't used for anything.
+ */
+ public enum DropEffect {
+ /**
+ * a copy of the source item is made at the new location.
+ */
+ COPY,
+
+ /**
+ * an item is moved to a new location.
+ */
+ MOVE,
+
+ /**
+ * a link is established to the source at the new location.
+ */
+ LINK,
+
+ /**
+ * the item may not be dropped.
+ */
+ NONE;
+ }
}