0
votes

I'm trying to drag an item from a datagrid and drop it onto a UIComponet. Basically I just want the UIComponent to know that something has been dropped onto it and allow it to access the data of the dropped item.

I thought just listening for the drop event would do it but it seems not.

I found lots of documentation on dragging from one IList to another but nothing for this.

<mx:UIComponent xmlns:mx="http://www.adobe.com/2006/mxml"
                initialize="init(event)" dragDrop="itemDropped(event)">
1

1 Answers

0
votes

You need to handle DRAG_ENTER too:

<s:TextInput id="input" dragEnter="input_dragEnterHandler(event)"
    dragDrop="input_dragDropHandler(event)"/>

Handlers:

private function input_dragEnterHandler(event:DragEvent):void
{
    var data:Array = event.dragSource.dataForFormat("items") as Array;
    if (data && data.length > 0)
        DragManager.acceptDragDrop(input);
}

private function input_dragDropHandler(event:DragEvent):void
{
    var data:Array = event.dragSource.dataForFormat("items") as Array;
    input.text = data[0].name;
}