Drag drop feedback not working

2 posts, 0 answers
  1. David
    David avatar
    2 posts
    Member since:
    Aug 2008

    Posted 18 Sep 2008 Link to this post

    OK, the title's a little bit of a lie.

    I am unable to figure out the right combination of property values and event handlers to get a behavior I need for dragging things around in a radtreeview.

    I want to allow users to drag node around in the tree (not into other controls).  This would seem to be very easy by simply setting the AllowDragDrop property to true.  This works great -- except that I need to implement some constraints.  Specifically, each type of node knows whether a given other node can be dropped onto it. 

    I was unable to find any event I could effectively hook to implement  this.  The documentation suggests that at the end when the drop happens (DragEnding) it's possible to apply some logic to determine if the drop is valid.  However this is not enough for me.  I want to provide real time feedback when the user is hovering over various nodes about whether they can drop there.

    So I started trying tsome things.  First I tried adding some feedback in the DragOver event.  But as soon as I did that, the visuals provided by the control (basically the bitmap being dragged around) moved a few pixels but then froze.  I finally concluded that I was colliding with the fully automatic drag drop capabilities in the control enabled by setting AllowDragDrop.

    So I turned off AllowDragDrop and initiated a DoDragDrop manually on the MouseMove event.  Then I started implementing the other normal Windows events (like DragOver).  In order to provide feedback, I change the colors of the potential target node.  This all works well *BUT* I can't figure out how to catch when the user cancels the drag-drop so I can restore the node to its original colors.  I can do this if the operation completes by changing it back in the DragDrop event, but I don't think that happens if the user hits escape while dragging.

    So... I thought I could hook QueryContinueDrag because it seems to have a flag indicating whether the user pressed Escape.  And here's the problem.  The event never seems to be called.  Is that a bug?  Is there something I need to do to cause the events to be fired?  My concern is that there is a bug such that QueryContinueDrag doesn't fire if the drag-drop operation is manually initiated (as I'm doing now).

    Any advice?  Is there a simpler way to make this work?  Is there a bug with firing QueryContinueDrag?




  2. Jordan
    Jordan avatar
    547 posts

    Posted 19 Sep 2008 Link to this post

    Hello David,

    Unfortunately, I see no way of knowing when the user cancels the drag and drop operation in every scenario.
    You could try however just setting the cursor to "No" when the mouse is over a specific node.

    Or you could wait until the next button release when an event called DragOverNode fires. Then all you need to do is something like:
    void radTreeView1_DragOverNode(object sender, RadTreeViewDragCancelEventArgs e) 
                e.Cancel = e.TargetNode.Nodes.Count > 2; 

    This will make the tree view change the cursor to "No" whenever in a drag and drop operation the mouse is over a node that has more than 2 children.

    Do not hesitate to write if you have any suggestions about this feature.

    BTW, how do you find the name of the event? What information will you need to have through the event arguments, etc..?

    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top