I fixed the problem, so now it works nice with both single and
multiselect
--- dTreeView.py 2007-01-11 14:03:41.913540000 +0100
+++ dTreeView_modified.py 2007-01-11 19:51:04.886427200 +0100
@@ -374,12 +374,19 @@
def __onTreeBeginDrag(self, evt):
if self._allowDrag(evt):
evt.Allow()
+ # We need to select the item being dragged
+ # so we don't try to drag an old selected item
+ self.SelectItem(evt.GetItem())
evt.Skip()
self.raiseEvent(dEvents.TreeBeginDrag, evt)
def __onTreeEndDrag(self, evt):
evt.Skip()
+ # We need to select only our destination node
+ if self.MultipleSelect:
+ self.UnselectAll()
+ self.SelectItem(evt.GetItem())
self.raiseEvent(dEvents.TreeEndDrag, evt)
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Simen Haugen
Sent: 11. januar 2007 15:52
To: Dabo Users list
Subject: [dabo-users] dTreeView multiselect
Theres a bug in dTreeView when using multiselect. If dragging only one
item, Selection isn't updated to the drop target.
import dabo
dabo.ui.loadUI('wx')
from dabo.ui import dEvents
class TestTree(dabo.ui.dTreeView):
def afterInit(self):
self.MultipleSelect = True
root = self.setRootNode('rootnode')
for gi in range(2):
group = self.appendNode(root,
'group')
for i in range(4):
self.appendNode(group,
'items%d'%i)
self._draggedItems = [] # Used to store the
items dragged
self.bindEvent(dEvents.TreeBeginDrag,
self.onBeginDrag)
self.bindEvent(dEvents.TreeEndDrag,
self.onEndDrag)
def onBeginDrag(self, evt):
self._draggedItems = self.Selection
def onEndDrag(self, evt):
tonode = self.Selection[0]
# If we are dragging only one item, the node we
are dropping
# to always is the node we are dragging!
if len(self._draggedItems) == 1:
print 'The same object?',
self._draggedItems[0] is tonode
else: # It works as expected when moving more
than one item
print 'The same object?', tonode in
self._draggedItems
self._draggedItems = []
class TestForm(dabo.ui.dForm):
def afterInit(self):
tree = TestTree(self)
self.Sizer.append1x(tree)
if __name__ == '__main__':
app = dabo.dApp()
app.setup()
app.MainForm = TestForm(None)
app.start()
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users