Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wxpython: How do I examine dragged data in OnDragOver?

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?

like image 586
Landon Kuhn Avatar asked Aug 25 '08 19:08

Landon Kuhn


2 Answers

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).

like image 109
Landon Kuhn Avatar answered Oct 15 '22 12:10

Landon Kuhn


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.

like image 24
DzinX Avatar answered Oct 15 '22 11:10

DzinX