New Method in treemixin - DragAndDrop?

Hi all,
hope that this is the right forum for my request:

We are using treemixin.py. Expecially DragAndDrop. With the existing method
"IsValidDropTarget" it's very easy to filter out all the unwanted targets. It
would be nice also to have a similar method to filter out all unwanted
drag-items.

That could be done very easy by implementing such a method and calling it in
OnBeginDrag:

    def OnBeginDrag(self, event):
        # We allow only one item to be dragged at a time, to keep it simple

        #-->start changes for using a method IsValidDragItem
# self._dragItem = event.GetItem()
# if self._dragItem and self._dragItem != self.GetRootItem():
        dragItem = event.GetItem()
        if self.IsValidDragItem(dragItem):
            self._dragItem = dragItem
        #-->stop changes for using a method IsValidDragItem
            self.StartDragging()
            event.Allow()
        else:
            event.Veto()

    def IsValidDragItem(self, dragItem):
        if dragItem and dragItem != self.GetRootItem():
            return True
        else:
            return False

Overloading IsValidDragItem makes it easy do customize the behaviour.

Any chance to get such a method in one of the next releases?

Thanks
Helmut Schierer

Hi Helmut,

···

2007/9/24, Helmut Schierer <helmut.schierer@dsa.at>:

We are using treemixin.py. Expecially DragAndDrop. With the existing method
"IsValidDropTarget" it's very easy to filter out all the unwanted targets. It
would be nice also to have a similar method to filter out all unwanted
drag-items.

This sounds not too hard. I'll have a look. If possible, can you send
me a patch, or simply your changed version of treemixin.py?

Cheers, Frank
(author treemixin.py)

Hi Helmut, Robin,

How about this (see attachment)? svn diff of
wx.lib.mixins.treemixin.py (WX_2_8_BRANCH).

Cheers, Frank

diff.txt (1.17 KB)

···

2007/9/24, Frank Niessink <frank@niessink.com>:

Hi Helmut,

2007/9/24, Helmut Schierer <helmut.schierer@dsa.at>:
> We are using treemixin.py. Expecially DragAndDrop. With the existing method
> "IsValidDropTarget" it's very easy to filter out all the unwanted targets. It
> would be nice also to have a similar method to filter out all unwanted
> drag-items.

This sounds not too hard. I'll have a look. If possible, can you send
me a patch, or simply your changed version of treemixin.py?

Cheers, Frank
(author treemixin.py)

Frank Niessink wrote:

Hi Helmut, Robin,

How about this (see attachment)? svn diff of
wx.lib.mixins.treemixin.py (WX_2_8_BRANCH).

Looks good to me.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Frank Niessink <frank <at> niessink.com> writes:

How about this (see attachment)? svn diff of
wx.lib.mixins.treemixin.py (WX_2_8_BRANCH).

Hi, Frank, Robin,

would be nice to have it in like you mentioned!

Cheers, Helmut

Helmut Schierer wrote:

Frank Niessink <frank <at> niessink.com> writes:

How about this (see attachment)? svn diff of
wx.lib.mixins.treemixin.py (WX_2_8_BRANCH).

Hi, Frank, Robin,

would be nice to have it in like you mentioned!

I checked it in to SVN yesterday. :wink:

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!