Adobe Integrated Runtime (AIR) for JavaScript Developers Pocket Reference

(nextflipdebug5) #1

110 | Chapter 4: AIR Mini-Cookbook


The typical flow for HTML elements that want to receive
drop operations are as follows:


1.User drags an item over the element listening for drop
events.
2.Element receives an ondragenterevent and specifies
which drop operations are available.
3.Element receivesondragoveroperations continuously as
the item is dragged over the element.
4.The user drops the item and the receiving element
receives anondrop event.
5.If the user moves the dragged item outside the bound-
aries of the listening element, it will receive an
ondragleave event.

Users can, by default, drag text elements and URLs. To dis-
able this functionality, use the-khtml-user-drag:nonestyle.
To override the default data type that is being specified, use
the-khtml-user-drag:elementstyle and specify listeners for
the drag events as specified previously.


To manipulate the data that is being transferred between
applications, use thedataTransferobject that is attached to
the event dispatched during drag operations. The
dataTransferobject has two methods,getDataandsetData.
ThesetDatamethod takes two parameters, the MIME type
and the string of data that conforms to that type. The
setDatamethod can be called multiple times and allows you
to store multiple data types. For example, if you wanted to
specify a “text/plain” type and a “text/uri-list” type, you
would do the following:


function dropStartListener( event )
{
event.dataTransfer.setData( "text/plain", "Adobe" );
event.dataTransfer.setData( "text/uri-list",
"http://www.adobe.com" );
}
Free download pdf