question on event order in drag and drop in TreeCtrl

Howdy,

I am trying to implement drag and drop in a tree control. I want to implement copy as well as move, so I am binding to
the control key. Control drag is a copy operation.

The way I have this implemented is to bind to two separate events.
I bind determing the control status to a mouse event EVT_LEFT_DOWN.
I bind the drop to the tree event EVT_TREE_END_DRAG.

The problem is that if the user changes their mind during the drag and wants to change copy/paste after
the drag is initiated, I can't do it.

It would seem a better way is to bind to EVT_LEFT_UP. So that the status at the end of the drop is what is
captured. The problem is that the mouse event fires after the tree event. So this doesn't work either.

Is there a way to get the control status from within the EVT_TREE_END_DRAG? or else is there
a way to make the mouse event fire before the tree event?

thanks,
Danny

Danny Shevitz wrote:

Howdy,

I am trying to implement drag and drop in a tree control. I want to implement copy as well as move, so I am binding to
the control key. Control drag is a copy operation.

The way I have this implemented is to bind to two separate events.
I bind determing the control status to a mouse event EVT_LEFT_DOWN.
I bind the drop to the tree event EVT_TREE_END_DRAG.

The problem is that if the user changes their mind during the drag and wants to change copy/paste after
the drag is initiated, I can't do it.

It would seem a better way is to bind to EVT_LEFT_UP. So that the status at the end of the drop is what is
captured. The problem is that the mouse event fires after the tree event. So this doesn't work either.

If you want to use the treectrl's internal DnD support then you should use the EVT_TREE_BEGIN_DRAG and EVT_TREE_END_DRAG pair. If you would rather use real DnD then you can use the mouse events to start it and use a DropTarget and DropSource, etc.

Is there a way to get the control status from within the EVT_TREE_END_DRAG?

wx.GetMouseState includes state info about the modifier keys. You can also check for them individually with wx.GetKeyState.

ยทยทยท

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!