Re: [flexcoders] Re: Tree drag drop: how to get node where item is dropped

2006-10-31 Thread Jim Laing
I just encountered this problem in our app this morning, and I thought
my solution might be helpful for someone out there. Building on
Peter's example (1), I also needed to allow a user to drag a new root
node onto the tree. That is, if they drag onto an existing node, add
it as a child. Otherwise, add it as a root. Below us a sketch of the
doDragDrop function I used. It's a hack, but it works:

private function doDragDrop(e:DragEvent):void {
  var items:Array = e.dragSource.dataForFormat(items) as Array;
  if(e.target == myTree) {
var tree:Tree = Tree(e.target);
var i:int = tree.calculateDropIndex(e);
tree.addEventListener(FlexEvent.VALUE_COMMIT, figureActionOut);
tree.selectedIndex = i;
tree.removeEventListener(FlexEvent.VALUE_COMMIT, figureActionOut);
function figureActionOut(e2:FlexEvent):void {
  if(tree.selectedIndex != i) {
trace(Add New Root(s));
  } else {
trace(Add Child(ren));
  }
}
  } 
}   

Hope that helps someone!

Jim

1. 
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=60catid=585threadid=1209910

On 10/30/06, kim_boulton [EMAIL PROTECTED] wrote:

 If you skim over to the Adobe Flex 2 General discussion forum. Peter
 Ent just showed me how to get this working.

 Easy too.

 hth

 kimb


 --- In flexcoders@yahoogroups.com, kim_boulton [EMAIL PROTECTED] wrote:
 
  Hello,
 
  Me too!
 
  kimb
 
  --- In flexcoders@yahoogroups.com, Niklas Richardson
  flexcoldfusion@ wrote:
  
   Hi there,
  
   Could you post your example code as I'm just trying to sort this out
  myself
   and running into the same problem.
  
   Thanks.
  
   Regards
  
   Niklas
  
  
  
  
   On 8/21/06, Jason Y. Kwong inlineblue@ wrote:
   
  I had posted a request to Adobe's wish form, asking that the
  drop data
be made available.  I got a very quick response (within 10
 minutes!):
   
Yes, we discovered this very soon after shipping that this data
  should
have been exposed. We have a bug for this already logged
  internally, so
we will work on fixing it for the future. For now, I think you
  will have
to rewrite your own updateDropData function, which is unfortunate.
   
So I'll have to stick with my original plan of duplicating a few
  methods
(as stated in my original post).
   
   
   
On 8/21/06, thunderstumpgesatwork thunder.stumpges@ wrote:

I'm glad it's not just me! So, were you able to get something
  working
 for your scenario?

 Anyone from the Adobe team want to confirm this and/or offer
 alternative solutions?

 thanks,
 Thunder

 --- In flexcoders@yahoogroups.com
  flexcoders%40yahoogroups.com, Jason
 Y. Kwong inlineblue@

 wrote:
 
  I've running into this myself right now as well. If you look
  at the
 Tree
  code, you can see that the drop parent is being tracked in the
 variable
  _dropData.parent. It gets calculated in the method
  updateDropData().
  Unfortunately, both the variable and the method are private, so
 they're
  useless as is (another example of Adobe being overly
 private, I'm
 afraid).
  I've had to duplicate (and tweak) the updateDropData() method to
 make use of
  the algorithm. The methods getChildIndexInParent() and
 getChildren() had to
  be duplicated as well.
 
  On 8/18/06, thunderstumpgesatwork thunder.stumpges@ wrote:
  
  
   Bump... I'm trying to do similar. Though I need to do it
 in the
   DragOver event, and determine under which node it is going
 to be
   dropped. I need to do this because certain places in the
  tree are
   acceptable places to drop certain items...
  
   I know I can get the dropIndex by using the tree function
   calculateDropIndex however this is not enough. It simply
  tells me
   where in the list of displayed nodes it will go. So if the
  item is
   being placed between the last item in a lower level node
 and the
   continuation of the next level up, the index is the same,
  but the
   parent of the ending drop is different.
  
   I can tell the Tree internals are tracking this because
 the drop
   indicator changes it's horizontal alignment to indicate
  which level
   it's going in...
  
   Anyone know how to determine the parent node of the
  indicated drop
   position?
  
   thanks,
   Thunder
  
  
   --- In flexcoders@yahoogroups.com
  flexcoders%40yahoogroups.comflexcoders%40yahoog
 roups.com,

 Jonas
   Windey jonas@ wrote:
   
Hi,
   
   
   
I have a tree with drag  drop enabled. Now what is the
  best way
 to
   find out
where the current selected item is dropped?
   
I'd need to know its parent (if it's not 

Re: [flexcoders] Re: Tree drag drop: how to get node where item is dropped

2006-10-27 Thread Niklas Richardson



Hi there,Could you post your example code as I'm just trying to sort this out myself and running into the same problem.Thanks.RegardsNiklas
On 8/21/06, Jason Y. Kwong [EMAIL PROTECTED] wrote:













  



I had posted a request to Adobe's wish form, asking that the drop data be made available. I got a very quick response (within 10 minutes!):Yes, we discovered this very soon after shipping that this data should
have been exposed. We have a bug for this already logged internally, sowe will work on fixing it for the future. For now, I think you will haveto rewrite your own updateDropData function, which is unfortunate.
So I'll have to stick with my original plan of duplicating a few methods (as stated in my original post).On 8/21/06, 
thunderstumpgesatwork
 [EMAIL PROTECTED] wrote:














  



I'm glad it's not just me!  So, were you able to get something working
for your scenario?

Anyone from the Adobe team want to confirm this and/or offer
alternative solutions?

thanks,
Thunder

--- In flexcoders@yahoogroups.com, Jason Y. Kwong [EMAIL PROTECTED]


wrote:

 I've running into this myself right now as well.  If you look at the
Tree
 code, you can see that the drop parent is being tracked in the
variable
 _dropData.parent.  It gets calculated in the method updateDropData().
 Unfortunately, both the variable and the method are private, so they're
 useless as is (another example of Adobe being overly private, I'm
afraid).
 I've had to duplicate (and tweak) the updateDropData() method to
make use of
 the algorithm.  The methods getChildIndexInParent() and
getChildren() had to
 be duplicated as well.
 
 On 8/18/06, thunderstumpgesatwork [EMAIL PROTECTED] wrote:
 
 
  Bump... I'm trying to do similar. Though I need to do it in the
  DragOver event, and determine under which node it is going to be
  dropped. I need to do this because certain places in the tree are
  acceptable places to drop certain items...
 
  I know I can get the dropIndex by using the tree function
  calculateDropIndex however this is not enough. It simply tells me
  where in the list of displayed nodes it will go. So if the item is
  being placed between the last item in a lower level node and the
  continuation of the next level up, the index is the same, but the
  parent of the ending drop is different.
 
  I can tell the Tree internals are tracking this because the drop
  indicator changes it's horizontal alignment to indicate which level
  it's going in...
 
  Anyone know how to determine the parent node of the indicated drop
  position?
 
  thanks,
  Thunder
 
 
  --- In flexcoders@yahoogroups.com flexcoders%40yahoog
roups.com,

Jonas
  Windey jonas@ wrote:
  
   Hi,
  
  
  
   I have a tree with drag  drop enabled. Now what is the best way to
  find out
   where the current selected item is dropped?
  
   I'd need to know its parent (if it's not on the rootnode), and the
  position
   where it's dropped inside that parent.
  
  
  
   Or is there an easier way to find the position? Like comparing the
   dataproviders before  after?
  
  
  
   Thanks for the tips,
  
   Jonas
  
 
   
 



  















  













-- Niklas RichardsonPrismix LtdUK based Flex and ColdFusion Specialists

__._,_.___





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








   






  
  
SPONSORED LINKS
  
  
  

Software development tool
  
  
Software development
  
  
Software development services
  
  


Home design software
  
  
Software development company
  

   
  






  
  Your email settings: Individual Email|Traditional 
  Change settings via the Web (Yahoo! ID required) 
  Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured 
   
Visit Your Group 
   |
  
Yahoo! Groups Terms of Use
   |
  
   Unsubscribe 
   
 

  




__,_._,___



Re: [flexcoders] Re: Tree drag drop: how to get node where item is dropped

2006-08-21 Thread Jason Y. Kwong



I had posted a request to Adobe's wish form, asking that the drop data be made available. I got a very quick response (within 10 minutes!):Yes, we discovered this very soon after shipping that this data should
have been exposed. We have a bug for this already logged internally, sowe will work on fixing it for the future. For now, I think you will haveto rewrite your own updateDropData function, which is unfortunate.
So I'll have to stick with my original plan of duplicating a few methods (as stated in my original post).On 8/21/06, thunderstumpgesatwork
 [EMAIL PROTECTED] wrote:













  



I'm glad it's not just me!  So, were you able to get something working
for your scenario?

Anyone from the Adobe team want to confirm this and/or offer
alternative solutions?

thanks,
Thunder

--- In flexcoders@yahoogroups.com, Jason Y. Kwong [EMAIL PROTECTED]

wrote:

 I've running into this myself right now as well.  If you look at the
Tree
 code, you can see that the drop parent is being tracked in the
variable
 _dropData.parent.  It gets calculated in the method updateDropData().
 Unfortunately, both the variable and the method are private, so they're
 useless as is (another example of Adobe being overly private, I'm
afraid).
 I've had to duplicate (and tweak) the updateDropData() method to
make use of
 the algorithm.  The methods getChildIndexInParent() and
getChildren() had to
 be duplicated as well.
 
 On 8/18/06, thunderstumpgesatwork [EMAIL PROTECTED] wrote:
 
 
  Bump... I'm trying to do similar. Though I need to do it in the
  DragOver event, and determine under which node it is going to be
  dropped. I need to do this because certain places in the tree are
  acceptable places to drop certain items...
 
  I know I can get the dropIndex by using the tree function
  calculateDropIndex however this is not enough. It simply tells me
  where in the list of displayed nodes it will go. So if the item is
  being placed between the last item in a lower level node and the
  continuation of the next level up, the index is the same, but the
  parent of the ending drop is different.
 
  I can tell the Tree internals are tracking this because the drop
  indicator changes it's horizontal alignment to indicate which level
  it's going in...
 
  Anyone know how to determine the parent node of the indicated drop
  position?
 
  thanks,
  Thunder
 
 
  --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com,

Jonas
  Windey jonas@ wrote:
  
   Hi,
  
  
  
   I have a tree with drag  drop enabled. Now what is the best way to
  find out
   where the current selected item is dropped?
  
   I'd need to know its parent (if it's not on the rootnode), and the
  position
   where it's dropped inside that parent.
  
  
  
   Or is there an easier way to find the position? Like comparing the
   dataproviders before  after?
  
  
  
   Thanks for the tips,
  
   Jonas
  
 
   
 



  















__._,_.___





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








   






  
  
SPONSORED LINKS
  
  
  

Web site design development
  
  
Computer software development
  
  
Software design and development
  
  


Macromedia flex
  
  
Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



  Visit your group "flexcoders" on the web.
  To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  






__,_._,___



Re: [flexcoders] Re: Tree drag drop: how to get node where item is dropped

2006-08-18 Thread Jason Y. Kwong



I've running into this myself right now as well. If you look at the Tree code, you can see that the drop parent is being tracked in the variable _dropData.parent. It gets calculated in the method updateDropData(). Unfortunately, both the variable and the method are private, so they're useless as is (another example of Adobe being overly private, I'm afraid). I've had to duplicate (and tweak) the updateDropData() method to make use of the algorithm. The methods getChildIndexInParent() and getChildren() had to be duplicated as well.
On 8/18/06, thunderstumpgesatwork [EMAIL PROTECTED] wrote:













  




Bump... I'm trying to do similar. Though I need to do it in the
DragOver event, and determine under which node it is going to be
dropped. I need to do this because certain places in the tree are
acceptable places to drop certain items...

I know I can get the dropIndex by using the tree function
calculateDropIndex however this is not enough. It simply tells me
where in the list of displayed nodes it will go. So if the item is
being placed between the last item in a lower level node and the
continuation of the next level up, the index is the same, but the
parent of the ending drop is different.

I can tell the Tree internals are tracking this because the drop
indicator changes it's horizontal alignment to indicate which level
it's going in... 

Anyone know how to determine the parent node of the indicated drop
position?

thanks,
Thunder

--- In flexcoders@yahoogroups.com, Jonas Windey [EMAIL PROTECTED] wrote:

 Hi, 
 
  
 
 I have a tree with drag  drop enabled. Now what is the best way to
find out
 where the current selected item is dropped?
 
 I'd need to know its parent (if it's not on the rootnode), and the
position
 where it's dropped inside that parent.
 
  
 
 Or is there an easier way to find the position? Like comparing the
 dataproviders before  after?
 
  
 
 Thanks for the tips,
 
 Jonas



  















__._,_.___





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








   






  
  
SPONSORED LINKS
  
  
  

Software development tool
  
  
Software development
  
  
Software development services
  
  


Home design software
  
  
Software development company
  

   
  







  
  
  YAHOO! GROUPS LINKS



  Visit your group "flexcoders" on the web.
  To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  






__,_._,___