From 83173c7a4d79083bc3ad7dd08a399cf970559e80 Mon Sep 17 00:00:00 2001 From: Roman Rolinsky Date: Wed, 10 Aug 2005 14:58:28 +0000 Subject: [PATCH] wxMSW fixes for tree control git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35166 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/wx/tools/XRCed/CHANGES.txt | 6 ++++++ wxPython/wx/tools/XRCed/globals.py | 2 +- wxPython/wx/tools/XRCed/tree.py | 19 ++++++++++++++++--- wxPython/wx/tools/XRCed/undo.py | 2 +- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/wxPython/wx/tools/XRCed/CHANGES.txt b/wxPython/wx/tools/XRCed/CHANGES.txt index cb43de5ba8..963d00880b 100644 --- a/wxPython/wx/tools/XRCed/CHANGES.txt +++ b/wxPython/wx/tools/XRCed/CHANGES.txt @@ -1,3 +1,9 @@ +0.1.6-2 +------- + +wxMSW wxTreeCtrl behaviour is still different from wxGTK for +wxTR_MULTIPLE, some fixes for this. + 0.1.6-1 ------- diff --git a/wxPython/wx/tools/XRCed/globals.py b/wxPython/wx/tools/XRCed/globals.py index cfcbc68dc3..4396304786 100644 --- a/wxPython/wx/tools/XRCed/globals.py +++ b/wxPython/wx/tools/XRCed/globals.py @@ -15,7 +15,7 @@ import sys # Global constants progname = 'XRCed' -version = '0.1.6-1' +version = '0.1.6-2' # Can be changed to set other default encoding different #defaultEncoding = '' # you comment above and can uncomment this: diff --git a/wxPython/wx/tools/XRCed/tree.py b/wxPython/wx/tools/XRCed/tree.py index 4c6817b535..01867d750f 100644 --- a/wxPython/wx/tools/XRCed/tree.py +++ b/wxPython/wx/tools/XRCed/tree.py @@ -419,6 +419,7 @@ class XML_Tree(wxTreeCtrl): EVT_TREE_ITEM_COLLAPSED(self, self.GetId(), self.OnItemExpandedCollapsed) self.selection = None + self.selectionChanging = False self.needUpdate = False self.pendingHighLight = None self.ctrl = self.shift = False @@ -486,7 +487,7 @@ class XML_Tree(wxTreeCtrl): self.root = self.AddRoot('XML tree', self.rootImage, data=wxTreeItemData(self.rootObj)) self.SetItemHasChildren(self.root) - self.Unselect() + self.UnselectAll() self.Expand(self.root) # Clear old data and set new @@ -510,7 +511,7 @@ class XML_Tree(wxTreeCtrl): self.mainNode.removeChild(node) node.unlink() self.Expand(self.root) - self.Unselect() + self.UnselectAll() # Add tree item for given parent item if node is DOM element node with # object/object_ref tag. xxxParent is parent xxx object @@ -641,7 +642,11 @@ class XML_Tree(wxTreeCtrl): return child def OnSelChanged(self, evt): - self.ChangeSelection(evt.GetItem()) + if self.selectionChanging: return + self.selectionChanging = True + self.UnselectAll() + self.SelectItem(evt.GetItem()) + self.selectionChanging = False def ChangeSelection(self, item): # Apply changes @@ -965,6 +970,14 @@ class XML_Tree(wxTreeCtrl): return False return not (self.IsExpanded(item) and self.GetChildrenCount(item, False)) + # Override to use like single-selection tree + def GetSelection(self): + self.GetSelections(self)[:1] + def SelectItem(self, item): + self.UnselectAll() + self.ChangeSelection(item) + wxTreeCtrl.SelectItem(self, item) + # Pull-down def OnRightDown(self, evt): pullDownMenu = g.pullDownMenu diff --git a/wxPython/wx/tools/XRCed/undo.py b/wxPython/wx/tools/XRCed/undo.py index 1f01d8d403..cc249884ee 100644 --- a/wxPython/wx/tools/XRCed/undo.py +++ b/wxPython/wx/tools/XRCed/undo.py @@ -74,7 +74,7 @@ class UndoCutDelete: g.testWin.highLight.Remove() g.tree.needUpdate = True self.elem = g.tree.RemoveLeaf(item) - g.tree.Unselect() + g.tree.UnselectAll() g.panel.Clear() class UndoPasteCreate: