I am trying to create a drag/drop system for pulling objects from one ObjectListView to another. I bind this event:
self.olv["music_dir"].Bind(wx.EVT_LIST_BEGIN_DRAG, self.handler.begin_music_dir_drag)
and then handle it like this:
def begin_music_dir_drag(self, event):
self.music_dir_dragging = True
self.music_dir_drag_target = event.GetEventObject().GetSelectedObject()
if not self.music_dir_drag_target:
self.music_dir_drag_target = event.GetEventObject().GetSelectedObjects()
Then I catch the "drop" with:
self.olv["music_playlist"].Bind(wx.EVT_LEFT_UP, self.handler.handle_playlist_stop_drag)
And handle it:
def handle_playlist_stop_drag(self, event):
if self.music_dir_dragging:
*** A bunch of irrelevant processing ***
self.gui_obj.frame.olv["music_playlist"].AddObjects(new_model_objs)
self.music_dir_dragging = False
self.music_dir_drag_target = None
So, this seems to work -- most of the time. There are times it works quickly with swift mouse movements. Other times it only works when I slow down and click and move deliberately. Other times it won't work at all many times in a row. I can't figure out why. Any thoughts?