I don't have time to look into it more right now.  There is drop-in-a-folder 
logic for empty folders in Tree.  Maybe you can leverage that logic.

From: [email protected] [mailto:[email protected]] On Behalf 
Of claudiu ursica
Sent: Monday, January 19, 2009 1:28 PM
To: [email protected]
Subject: Re: [flexcoders] Drag And Drop Tree

It can be moved around but cannot be dropped into a folder (branch) unless the 
folder is open. I was adding those handlers, so that i can drop item/items 
inside a closed node... And it works for branches but not for leaf nodes ...

Setting breakpoints in drag/drop generally doesn’t work because you tend to 
release the mouse in order to dig through the debugging info and when you 
resume the drag is cancelled.

The funny thing is that the accurate data seems to be there at a certain time 
when debugged, and i tried to store it in a private member of the component and 
that works fine for branches, it seems that it just looses the data it probably 
when dragging over a branch or I don''t know, but the length is still one so I 
end up in adding an empty leaf. That also happens for the dragComplete handler. 
Still adding an empty leaf...



________________________________
From: Alex Harui <[email protected]>
To: "[email protected]" <[email protected]>
Sent: Monday, January 19, 2009 11:01:07 PM
Subject: RE: [flexcoders] Drag And Drop Tree
If I remove your handlers, I can move Sent just fine.  In your handler the 
following line is suspicious:

var xml : XML = new XML(items);

because items is an array.  Use XML.toXMLString( ) to make sure you’re trying 
to put in valid data.

From: flexcod...@yahoogro ups.com<http://ups.com> [mailto:flexcoders@ 
yahoogroups. com] On Behalf Of claudiu ursica
Sent: Monday, January 19, 2009 12:30 AM
To: flexcod...@yahoogro ups.com
Subject: Re: [flexcoders] Drag And Drop Tree

Hi Alex,
I can move simple leafs from the root under a folder with no custom handlers, 
if the folder is open. However the thing is that I need to just put (maybe just 
copy not move) the item let's say for argument sake "<node label="Sent"/>" 
under "Inbox" folder. I cannot do that unless the "sent" is under some folder 
and move it with the folder, because otherwise the DragSource seeems to return 
an item but I cannot get the data from that item. So I end up dropping an empty 
item. However as said before If I move/copy a folder with items around it works 
fine ... The same happends with the drag complete handler, for just one item 
the drags source traces out to blank event though the length is 1.

Claudiu

________________________________
From: Alex Harui <aha...@adobe. com>
To: "flexcod...@yahoogro ups.com" <flexcod...@yahoogro ups.com>
Sent: Monday, January 19, 2009 7:47:53 AM
Subject: RE: [flexcoders] Drag And Drop Tree
Setting breakpoints in drag/drop generally doesn’t work because you tend to 
release the mouse in order to dig through the debugging info and when you 
resume the drag is cancelled.

Remove the custom drag event handlers and try with simple data and see if it 
works.  We definitely tested drag/drop in Tree so basic cases work.  One trick 
for Tree is that what happens on drop is different than in List.  The node is 
removed before it is added in Tree, and sometimes that is done in dragComplete 
handler instead of dragDropHandler

From: flexcod...@yahoogro ups.com<http://ups.com> [mailto:flexcoders@ 
yahoogroups. com] On Behalf Of Claudiu Ursica
Sent: Sunday, January 18, 2009 9:59 AM
To: flexcod...@yahoogro ups.com
Subject: [flexcoders] Drag And Drop Tree


Hi I'm trying to implement the drag and drop functionality inside a
tree, dragging and dropping inside the same tree. However It seems
that I cannot drag and drop leaf nodes... When I handle enterDrag
event the item seems to be appearing only at debug time and gets lost
after that...

here is the code..

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe. com/2006/ 
mxml<http://www.adobe.com/2006/mxml>"
layout="absolute">

<mx:Script>
<![CDATA[
import mx.events.DragEvent ;
import mx.managers. DragManager;
import mx.core.UIComponent ;
import mx.core.DragSource;



private function onDragEnter( event : DragEvent) : void
{
var items : Array = event.dragSource. dataForFormat("treeItems") as
Array;

trace("items ", items);
//this only shows data for branches

//if I try drag drop a leaf like spam for
//instance I can see the node only when debugginh and when
resuming the data is gone
//when resuming even though the length is 1
}

/**
* The dragDrop event is dispatched when the mouse is released.
* The Tree can still ignore the drop here
*/
private function onDragDrop(event : DragEvent) : void
{
var ds : DragSource = event.dragSource;

var items : Array = ds.dataForFormat("treeItems") as Array;
trace("items ", items);
//this display actually the drop node instead of the dragsource

var dropTarget : Tree = Tree(event.currentT arget);

var selectedIndex : int = myTree.calculateDro pIndex(event) ;

myTree.selectedInde x = selectedIndex;

var node : XML = myTree.selectedItem as XML;
var dropParent : *;

// if the selected node has children
// then add the items at the beginning
if(myTree.dataDescr iptor.hasChildre n(node))
{
dropParent = node;
selectedIndex = 0;
}
else
{
dropParent = node.parent( );
}

// taking all of the items in the DragSouce, insert them into the
// tree using parent pointer.
// taking all of the items in the DragSouce, insert them into the
// tree using parent pointer.
var xml : XML = new XML(items);
var sucess : Boolean =
myTree.dataDescript or.addChildAt( dropParent, xml, selectedIndex) ;

//trace(sucess) ;

}



]]>
</mx:Script>

<mx:Tree id="myTree"
width="300"
height="100%"
labelField="@label"
showRoot="false"
dataProvider="{treeData}"
borderStyle="none"
dragEnabled="true"
dragMoveEnabled="true"
dropEnabled="true"
dragEnter="onDragEnter( event)"
dragDrop="onDragDrop(event)">
</mx:Tree>

<mx:XMLList id="treeData">
<node label="Mail Box">
<node label="Inbox">
<node label="Marketing"/>
<node label="Product Management"/>
<node label="Personal"/>
</node>
<node label="Inbox">
<node label="Marketing"/>
<node label="Product Management"/>
<node label="Personal"/>
</node>
<node label="Inbox">
<node label="Marketing"/>
<node label="Product Management"/>
<node label="Personal"/>
</node>
<node label="Outbox">
<node label="Professional"/>
<node label="Personal"/>
<node label="Inbox">
<node label="Marketing"/>
<node label="Product Management"/>
</node>
<node label="Personal"/>
</node>
<node label="De mutat">
<node label="Unu"/>
<node label="Doi"/>
<node label="DoiUnu">
<node label="DoiUnuUnu"/>
<node label="DoiUNuDoi"/>
</node>
<node label="Trei"/>
</node>
<node label="Spamu"/>
<node label="Sent"/>
<node label="Movable"/>
</node>
</mx:XMLList>

</mx:Application>

so the code seems to be working when drag and dropping an folder but
not when dropping a leaf, I get a new Item with no label.
I have searched the archives for something similar and found only the
same issue posted twice by 2 different guys and no answers. So I
thought I'll have better luck...

TIA,
Claudiu



Reply via email to