Adobe Integrated Runtime (AIR) for JavaScript Developers Pocket Reference

(nextflipdebug5) #1
Drag and Drop | 111

IfsetDatais called for a MIME type that already exists on the
element being dragged, that data will be overwritten. Retriev-
ing data from an element that is being dragged can occur
only within anondropevent handler. ThegetDatamethod
takes a MIME type as its only parameter and returns the
value of the MIME type if it exists on the element being
dragged. For example:


function dropListener( event )
{
alert( event.dataTransfer.getData( "text/plain" ) );
// Adobe
}

When a user is dragging an item from one application to
another, or from one location in your application to another,
you may want to indicate to the user which operations (copy,
link, or move) are available. By using theeffectAllowedand
dropEffectproperties of thedataTransferobject you can
specify which operations are allowed. The system then uses
the application to determine what actions a user can per-
form during the drag operation. The list of available values
for these properties can be determined by reading the docu-
ment referenced above.


When starting a drag, theeffectAllowedproperty tells the
system what operations the source element supports. The
dropEffectproperty specifies the operation that the current
target receiving the drag event supports. The system then
uses the information about what effects both the source and
destination target support and displays that to the user.


TIP
The current AIR Beta on Adobe Labs has a few limita-
tions. First, specifying custom drag images and snap-
shots is not supported. Also, only two MIME types are
available for transfer: text/plain, and text/uri-list. Last,
the types array on thedataTransferis not accessible on
thedataTransferobject. Support for these features will be
added for AIR Version 1.0.
Free download pdf