Tuesday, April 19, 2011

Working with clipboard in AIR: Part 6

Today we'll start learning about drag-and-dropping in AIR.

Now that we have learned about using clipboard to copy and paste data, we can move on to drag-and-dropping. This operation also uses clipboard.

Here's what basically happens once the user drag and drops an object onto some specified area:

Firstly, the user initiates the operation by performing an action, for example, click the object. After that, the data is send to the clipboard. The user is dragging the object. The user drops the object, and if it was dropped in the specified target area - data is extracted from clipboard.

The object in this situation is called the initiator. The final area where the object is being dragged into is called the target area.

There are events for each of the stage of the operation in AIR. All of them are the constants of NativeDragEvent:

NATIVE_DRAG_START - distributed by the initiator - the user starts dragging.
NATIVE_DRAG_UPDATE - distributed by the initiator - the process of the dragging.
NATIVE_DRAG_COMPLETE - distributed by the initiator - the user lets go of the object.
NATIVE_DRAG_ENTER - distributed by the target area - the user drags the object into the area.
NATIVE_DRAG_OVER - distributed by the target area - the dragging is happening inside of the area.
NATIVE_DRAG_EXIT - distributed by the target area - the user drags the object out of the the area.
NATIVE_DRAG_DROP - distributed by the target area - the user drops the object in the target area.

All the events of NativeDragEvent type have a property called clipboard. This refers to the Clipboard object that contains the data for the operation of drag-and-dropping.

This is all, for now.

Thank you for reading.

Related:

Working with clipboard in AIR: Part 1
Working with clipboard in AIR: Part 2
Working with clipboard in AIR: Part 3
Working with clipboard in AIR: Part 4
Working with clipboard in AIR: Part 5
Working with clipboard in AIR: Part 7
Working with clipboard in AIR: Part 8
Working with clipboard in AIR: Part 9
Working with clipboard in AIR: Part 10

No comments:

Post a Comment