Flex -- Drag enable leaf nodes only in tree component
Is there a way to enable dragging of only leaf nodes in a tree c开发者_运维问答omponent?
First you need to intercept the dragStart event from your tree
dragStart="tree_dragStartHandler(event)"
Then in the event handler you can check to see if the selected item is a branch, if it is then you cancel the dragStart event's default behavior with preventDefault()
protected function tree_dragStartHandler(event:DragEvent):void
{
var item:Object = event.currentTarget.selectedItem
if (tree.dataDescriptor.isBranch(item)) {
event.preventDefault();
}
}
精彩评论