def OnMotion(self, event):
pos = event.GetPosition()
if event.Dragging() and event.LeftIsDown():
if not self.dragImage:
self.dragImage = WxDragImage(self.GetBackgroundColour
())
self.dragImage.BeginDrag(wx.Point(0,0), self,
fullScreen=True)
self.dragImage.Show()
self.dragImage.Move(pos)
As per the docs:
dropSource.DoDragDrop(wx.Drag_DefaultMove)
This will capture the mouse and won't release untill the drag-drop
completed.
"OnMotion" is not getting is called because of this. If you comment
the line
self.startDragOperation()
drag image is drawn properly.
In demo->Clipboard and Dnd->CustomDragAndDrop.
How do you get the source window from which drag has started in class
"DoodleDropTarget".
You can't. The source of the DnD may be in a different process than the target that is receiving the data, or in some environments it could even be on a different machine. All you can do is get the data that the source provides and return a message to the source indicating whether that data was ignored, copied or moved.
In my implementation of DnD and DragImage both, there are some
problems.
The code:
def OnMotion(self, event):
pos = event.GetPosition()
if event.Dragging() and event.LeftIsDown():
if not self.dragImage:
self.dragImage = WxDragImage(self.GetBackgroundColour
())
self.dragImage.BeginDrag(wx.Point(0,0), self,
fullScreen=True)
self.dragImage.Show()
self.dragImage.Move(pos)
As per the docs:
dropSource.DoDragDrop(wx.Drag_DefaultMove)
This will capture the mouse and won't release untill the drag-drop
completed.
"OnMotion" is not getting is called because of this. If you comment
the line
self.startDragOperation()
drag image is drawn properly.
This is by-design. The DoDragDrop is a modal operation, meaning that program control does not return to the caller until after the operation is complete, just like a modal dialog's ShowModal method. Normally the system will show standard drag feedback for you, but if you really need to override the default behavior you can do it by overriding the GiveFeedback method in your drop source class.