+ EVT_WINDOW_DESTROY(self, self.OnDestroy)
+
+ def OnDestroy(self, evt):
+ # This is how the clipboard contents can be preserved after
+ # the app has exited.
+ wxTheClipboard.Flush()
+ evt.Skip()
+
+
+ def OnStartDrag(self, evt):
+ self.log.write("OnStartDrag: %d, %s\n"
+ % (evt.GetDragAllowMove(), evt.GetDragText()))
+
+ if debug and evt.GetPosition() < 250:
+ evt.SetDragAllowMove(False) # you can prevent moving of text (only copy)
+ evt.SetDragText("DRAGGED TEXT") # you can change what is dragged
+ #evt.SetDragText("") # or prevent the drag with empty text
+
+
+ def OnDragOver(self, evt):
+ self.log.write("OnDragOver: x,y=(%d, %d) pos: %d DragResult: %d\n"
+ % (evt.GetX(), evt.GetY(), evt.GetPosition(), evt.GetDragResult()))
+
+ if debug and evt.GetPosition() < 250:
+ evt.SetDragResult(wxDragNone) # prevent dropping at the beginning of the buffer
+
+
+ def OnDoDrop(self, evt):
+ self.log.write("OnDoDrop: x,y=(%d, %d) pos: %d DragResult: %d\n"
+ "\ttext: %s\n"
+ % (evt.GetX(), evt.GetY(), evt.GetPosition(), evt.GetDragResult(),
+ evt.GetDragText()))
+
+ if debug and evt.GetPosition() < 500:
+ evt.SetDragText("DROPPED TEXT") # Can change text if needed
+ ##evt.SetDragResult(wxDragNone) # Can also change the drag operation, but it
+ # is probably better to do it in OnDragOver so
+ # there is visual feedback
+
+ ##evt.SetPosition(25) # Can also change position, but I'm not sure why
+ # you would want to...
+
+
+