Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

DragDropEffects.Link Cursor

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
rnemchev



Joined: 26 Apr 2010
Posts: 12

PostPosted: Mon May 17, 2010 2:25 pm    Post subject: DragDropEffects.Link Cursor Reply with quote

Hi,

I have implemented drag and drop using appropriate events of the virtual tree. However when I set drag/drop effect to DragDropEffects.Link in GetRowDropEffect handler the shown cursor is wrong - instead of link cursor I get DragDropEffects.None (forbidden) cursor. When I set drag/drop effect to Move or Copy everything is OK (the proper cursors are shown).
I tried to set my own cursor using ViretualTree.DragLinkCursor property but without success.

Can you give me a clue?
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue May 18, 2010 12:19 am    Post subject: Reply with quote

Are you trying to drag into or from VirtualTree (or both)?

I think that probably you have handled the GetRowDropEffect event however you haven't handled the GetAllowedRowDropLocations event. If you are dragging custom data into VirtualTree then you will need to handle this event and set the e.AllowedDropLocations - otherwise you won't be allowed to drop the data. I've checked by modifying the Simple Tree sample and was able to set the RowDropEffect to link without any issues (ie it displayed the link cursor).
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
rnemchev



Joined: 26 Apr 2010
Posts: 12

PostPosted: Tue May 18, 2010 8:52 am    Post subject: Reply with quote

I have handled both GetRowDropEffect event and GetAllowedRowDropLocations event. I suspect that because my drag starts from the tree and the drop is in the same tree the link behavior is not allowed.

This is my implementation (I am using custom IList implementation for binding):

protected override RowDropLocation AllowedRowDropLocations( Row row, IDataObject data )
{
return RowDropLocation.OnRow;
}
protected override bool AllowRowDrag( Row row )
{
return true;
}
protected override DragDropEffects RowDropEffect( Row row, RowDropLocation dropLocation, IDataObject data )
{
return DragDropEffects.Link;
}
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue May 18, 2010 9:39 am    Post subject: Reply with quote

You are right there is an issue when Virtual Tree is the source of the drag event. The reason for this is rather curious. To initiate the drag operation the RowWidget.DoDragDrop method calls:

Code:
WidgetControl.DoDragDrop(this, Tree.SelectedRows.GetRows(), DragDropEffects.All);


However strangely enough (and contrary to the Microsoft documentation) DragDropEffects.All does not include DragDropEffects.Link. To work around this issue you can override the VirtualTree.DoDragDrop method as follows to force the allowed drag effects to include Link:

Code:
   class MyTree : VirtualTree
    {
        public override void DoDragDrop(Widget widget, object data, System.Windows.Forms.DragDropEffects allowedEffects)
        {
            allowedEffects = allowedEffects | DragDropEffects.Link;
            base.DoDragDrop(widget, data, allowedEffects);
        }
    }


We will change the RowWidget.DoDragDrop method in a future release to explicity include the Link effect (instead of using .All)
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
rnemchev



Joined: 26 Apr 2010
Posts: 12

PostPosted: Tue May 18, 2010 2:54 pm    Post subject: Reply with quote

Thank you! Your solution works fine.

Rado
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Jun 29, 2010 2:29 am    Post subject: Reply with quote

Version 3.15.1 has now been released and fixes this issue (so that you do not need to override DoDragDrop)
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group