1 Reply Latest reply on Jan 14, 2008 5:24 PM by rubensr

    Tree - controlling drag feedback during drag

    rubensr
      I am implementing drag & drop inside a tree component (ie rearranging elements inside the tree), but cannot find a way to dynamically check the parent of the possible drop node during the dragOver event. The calculateDropIndex() function returns the same index for both drop positions shown in the example tree below.



      0) Item a
      1) Item b
      ____2) Item c
      ____(Insertion point 1)
      (Insertion point 2)
      3) Item d



      (for both insertion points above, calculateDropIndex() returns 3, fair enough, but how to I find out the parent _BEFORE_ the node is dropped?)

      I understand some people pointed to Peter Ent's tree examples in other threads, but those are not good enough - they do not extend the default tree behaviour of the tree (ie being able to drop one node between two nodes).

      What I need to do is to be able to check exactly where the dragged node is being possibly dropped and programmatically reject or accept the dragOver.

      Any help is appreciated.
      Rubens
        • 1. Re: Tree - controlling drag feedback during drag
          rubensr Level 1
          Ok I found the answer - which is a hack really, because the way the drag and drop support is implemented in Tree is weird:

          1) All the information needed to provide visual feedback to the user during a drag operation is hidden away in an mx_internal variable;
          2) That information is updated at the same time the tree drop indicators are drawn and the drop feedback is shown - so when you override dragOverHandler(), you need to call "showDropFeedback()" first, check the drop node parent, and then hide it if needed, by calling hideDropFeedback().

          Anyway, here is a link to the workaround:
          http://tech.groups.yahoo.com/group/flexcoders/message/88721

          Hope this helps
          Rubens