I'm a bit perplexed by drag and drop in wxPython (but perhaps this questions pertains to drag and drop in other GUI frameworks as well). The frameworks provides a couple of callbacks (OnEnter and OnDragOver) that purportedly allow me to inform the system whether the current mouse position is a valid place to drop whatever it is that is being dragged. From these methods I can return wx.DragNone, wx.DragCopy, etc. What baffles me is that from within these methods I am not allowed to call GetData, which means I am not allowed to examine the data that the user is dragging. If I cannot see the data, how am I supposed to know whether it is OK for the user to drop here?
+1
A:
One solution, which is a hack of limited usefulness, is when a drag is initiated, store the dragged data in a global or static reference somewhere. This way, in the OnEnter and OnDragOver handlers, it is possible to get a reference to the data being dragged. This is of course only useful for drags within the same application (the same instance of the application, actually).
landon9720
2008-08-25 19:45:40
+1
A:
There is no way to see dragged data in OnEnter
and OnDragOver
methods.
The only solution I found is to store the dragged item in some instance variable that is then readable inside these methods.
DzinX
2008-09-26 12:15:24
Can you expand on this a little. I was/am planning on using Wx for a fun project. Dragging with a x/y return, was something I was counting on.
J.J.
2008-10-01 13:21:59
Oh, you CAN see where the data is dropped into, you just cannot see what is being dragged while dragging (before user lets go of the mouse button), which is sometimes useful (e.g. if you want to change the mouse pointer depending on dragged content).
DzinX
2008-10-01 17:22:12