Dataview control drag and drop

Dear all,

I am trying to setup drag and drop for a DataViewControl so that it works on linux, OSX and windows and I am having troubles with the linux part. Let me share all my observations, maybe it helps to identify where the problem is. I am testing on windows, OSX and linux (ubuntu) with python 3.8 and wxpython 4.1.0.

First of all I noticed that the requirements to get it work are quite different on linux/windows and OSX on the other hand. The linux and windows implementations seem to be based on general wx drag and drop even though dataview has its own EVT_DATAVIEW_… events for that whereas on OSX it feels like an internal dataview mechanism. In more detail, on windows an linux it is neccesary to call

EnableDragSource(wx.DataFormat(wx.DF_UNICODETEXT))
EnableDropTarget(wx.DataFormat(wx.DF_UNICODETEXT))

on the DataViewControl and create a DataObject in the the drag event handler, i.e.

    def _onDrag(self, evt):
        evt.SetDataObject(wx.TextDataObject('this text will be recevied by drop targets that accept text'))
        evt.SetDragFlags(wx.Drag_AllowMove)

On OSX it is sufficient to bind to the EVT_DATAVIEW_ITEM_BEGIN_DRAG and EVT_DATAVIEW_ITEM_DROP events without doing anything more.

One problem on linux is that apparently the EVT_DATAVIEW_ITEM_DROP_POSSIBLE event is never triggered, i.e. it is not possible to control the visual feedback while dragging whether the item is at a place where it may be dropped or not. I am currently checking with wxwidgets3.1 on the same platform and there it seems that the event is fired but only in the moment when the item is dropped (mouse released).

The other problem on linux is that when I try to drag a group of items (with DV_MULTIPLE selected) in the moment I click and begin to drag the selection is cleared and the only item that moves is that one which received the last mouse click. This is exactly the same with wxwidgets, so I will ask over there.

I really like the way drag and drop is implemented in the OSX port. I am not able to test wxwidgets on OSX so I cannot say if this is done in the python layer or if it is a native mechanism. But I would love to have it as simple on all platforms.

Christian

wxPython doesn’t do any Python-specific customization for DVC DnD, except for dealing with the data buffer in DataViewEvent.GetDataBuffer.

Ok, thanks. Then I will ask at wxwidgets. And I need to correct me, the EVT_DATAVIEW_DROP_POSSIBLE is actually called exactly once: just before dropping (releasing the mouse). This is exactly the same behaviour as with wxwidgets.

Christian