Add
the data for the drag gesture in the handler for the
dragstart
event
with the
dataTransfer
property. Use the
dataTransfer.setData()
method to
put data onto the clipboard, passing in the MIME type and the data
to transfer.
For example, if you had an image element in your application,
with the id
imageOfGeorge
, you could use the following dragstart
event handler. This example adds representations of a picture of
George in several data formats, which increases the likelihood that
other applications can use the dragged data.
function dragStartHandler(event){
event.dataTransfer.effectAllowed = "copy";
var dragImage = document.getElementById("imageOfGeorge");
var dragFile = new air.File(dragImage.src);
event.dataTransfer.setData("text/plain","A picture of George");
event.dataTransfer.setData("image/x-vnd.adobe.air.bitmap", dragImage);
event.dataTransfer.setData("application/x-vnd.adobe.air.file-list",
new Array(dragFile));
}
Note:
When you call the
setData()
method
of
dataTransfer
object, no data is added by the
default drag-and-drop behavior.