Browse Source

wxGUI/GSelect: filtering items in progress, see https://trac.osgeo.org/grass/ticket/1251 (https://trac.osgeo.org/grass/changeset/44725 cont'ed)
patch by Anna Kratochvilova


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@44734 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 14 years ago
parent
commit
5aa88928b1
1 changed files with 10 additions and 13 deletions
  1. 10 13
      gui/wxpython/gui_modules/gselect.py

+ 10 - 13
gui/wxpython/gui_modules/gselect.py

@@ -77,10 +77,10 @@ class Select(wx.combo.ComboCtrl):
             self.tcp.SetData(type = type, mapsets = mapsets,
             self.tcp.SetData(type = type, mapsets = mapsets,
                              multiple = multiple,
                              multiple = multiple,
                              updateOnPopup = updateOnPopup, onPopup = onPopup)
                              updateOnPopup = updateOnPopup, onPopup = onPopup)
-        self.GetChildren()[0].Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
+        self.GetChildren()[0].Bind(wx.EVT_KEY_UP, self.OnKeyUp)
      
      
-    def OnKeyDown(self, event):
-        """!Shows popupwindow if down arrow key is pressed"""
+    def OnKeyUp(self, event):
+        """!Shows popupwindow if down arrow key is released"""
         if event.GetKeyCode() == wx.WXK_DOWN:
         if event.GetKeyCode() == wx.WXK_DOWN:
             self.ShowPopup() 
             self.ShowPopup() 
         else:
         else:
@@ -185,10 +185,6 @@ class TreeCtrlComboPopup(wx.combo.ComboPopup):
     def SetFilter(self, filter):
     def SetFilter(self, filter):
         """!Set filter for GIS elements, see e.g. VectorSelect"""
         """!Set filter for GIS elements, see e.g. VectorSelect"""
         self.filterElements = filter
         self.filterElements = filter
-        
-    def _startsWith(self, text):
-        """!Filter items - currently unused"""
-        return True if text.startswith(self.GetCombo().GetValue()) else False
     
     
     def OnPopup(self, force = False):
     def OnPopup(self, force = False):
         """!Limited only for first selected"""
         """!Limited only for first selected"""
@@ -207,10 +203,6 @@ class TreeCtrlComboPopup(wx.combo.ComboPopup):
         if inputText:
         if inputText:
             root = self.seltree.GetRootItem()
             root = self.seltree.GetRootItem()
             match = self.FindItem(root, inputText, startLetters = True)
             match = self.FindItem(root, inputText, startLetters = True)
-            if wx.TreeItemId.IsOk(self.seltree.GetPrevSibling(match)):
-                match = self.seltree.GetPrevSibling(match)
-            else: 
-                match = self.seltree.GetItemParent(match)
             self.seltree.EnsureVisible(match)
             self.seltree.EnsureVisible(match)
             self.seltree.SelectItem(match)
             self.seltree.SelectItem(match)
             
             
@@ -460,8 +452,13 @@ class TreeCtrlComboPopup(wx.combo.ComboPopup):
                 mapsetItem = self.seltree.GetItemParent(item)
                 mapsetItem = self.seltree.GetItemParent(item)
                 fullName = self.seltree.GetItemText(item) + '@' \
                 fullName = self.seltree.GetItemText(item) + '@' \
                             + self.seltree.GetItemText(mapsetItem).split(' ', 1)[1]
                             + self.seltree.GetItemText(mapsetItem).split(' ', 1)[1]
-                self.value = [fullName, ]
-                self.Dismiss()
+                if self.multiple is True:
+                    # text item should be unique
+                    self.value.append(fullName)
+                else:
+                    self.value = [fullName, ]
+            
+            self.Dismiss()
 
 
     def OnMotion(self, evt):
     def OnMotion(self, evt):
         """!Have the selection follow the mouse, like in a real combobox
         """!Have the selection follow the mouse, like in a real combobox