Hi Everyone,
I'm having a really annoying problem that I can't seem to solve. I have a
custom built tree component (built from a List) using the Flex 4 SDK. I need to
drag an item from this list into another custom List component (the only
customization here is the Skin).
I can get the tree items to drag just fine. However, I cannot get the second
list to accept the dragDrop. I have set dragEnabled and dropEnabled to true.
When I use "this as IUIComponent" as the target in DragManager.acceptDragDrop,
it does not work. I still see the cursor with the red X and the dragDrop event
does not first.
If I use the dragInitiator, or the dataGroup of the List, I see the correct
"Copy" indicator but no dropEvent gets fired. I assume that's becuase I have
not set the list as a valid drop target. I have tried this by listening on
dragEnter and dragDrop events and also by overriding the dragEnterHandler and
dragDropHandler on the list. Below is my code:
/** @inheritDoc spark.components.List#dragEnterHandler **/
protected override function dragEnterHandler(e:DragEvent):void {
if ( e.dragSource.hasFormat("presentationFromTree") ) {
DragManager.acceptDragDrop(this as
IUIComponent);
DragManager.showFeedback(DragManager.COPY);
} else {
DragManager.showFeedback(DragManager.NONE);
}
}
/** @inheritDoc spark.components.List#dragDropHandler **/
protected override function dragDropHandler(e:DragEvent):void {
if ( e.dragSource.hasFormat("presentationFromTree") ) {
// Handle the dropping of data from the
fileManager tree
var itemData:XML =
XML(e.dragSource.dataForFormat("presentationFromTree"));
handleDropFromTree(itemData);
}
}
Any thoughts or ideas on how I can get this work? Many thanks in advance!