views:

18

answers:

1

Hi,

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)">
A: 

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;
}
Maxim Kachurovskiy
Cool, by UIComponent can now accept drops. I think however that I'm going to have to ditch the dragManager all together and comeup with my own solution. The reason being is I wanted to use a custom drag proxy image which requires manually setting up the drag manager. When setting the drag inititator in the dodrag method I can only pass in the datagrid, not the datagrid row item that was clicked which messes up the position of my proxy image. It always gets attached at the x,y of the dg and not of therow itsself
dubbeat
scratch that, I dicked around with the dodrag offest and got it positioned ok.
dubbeat