+ self.Bind(stc.EVT_STC_DO_DROP, self.OnDoDrop)
+ self.Bind(stc.EVT_STC_DRAG_OVER, self.OnDragOver)
+ self.Bind(stc.EVT_STC_START_DRAG, self.OnStartDrag)
+ self.Bind(stc.EVT_STC_MODIFIED, self.OnModified)
+
+ self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)
+
+ def OnDestroy(self, evt):
+ # This is how the clipboard contents can be preserved after
+ # the app has exited.
+ wx.TheClipboard.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):
+ #Todo: evt.GetdragResult() response is not an int
+
+ 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(wx.DragNone) # 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(wx.DragNone) # 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...
+
+