Browse Source

wxGUI/prompt: up/down - list history/modules right - get list of modules
(merge https://trac.osgeo.org/grass/changeset/39937 from devbr6)


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

Martin Landa 15 years ago
parent
commit
2218930287
1 changed files with 33 additions and 13 deletions
  1. 33 13
      gui/wxpython/gui_modules/prompt.py

+ 33 - 13
gui/wxpython/gui_modules/prompt.py

@@ -240,9 +240,10 @@ class TextCtrlAutoComplete(wx.ComboBox, listmix.ColumnSorterMixin):
         # some variables
         self._choices = choices
         self._hideOnNoMatch = True
-        self._module = None # currently selected module
-        self._choiceType = None # type of choice (module, params, flags, raster, vector ...)
+        self._module = None      # currently selected module
+        self._choiceType = None  # type of choice (module, params, flags, raster, vector ...)
         self._screenheight = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y)
+        self._historyItem = 0   # last item
         
         # sort variable needed by listmix
         self.itemDataMap = dict()
@@ -571,18 +572,37 @@ class TextCtrlAutoComplete(wx.ComboBox, listmix.ColumnSorterMixin):
         sel = self.dropdownlistbox.GetFirstSelected()
         visible = self.dropdown.IsShown()
         KC = event.GetKeyCode()
-        if KC == wx.WXK_DOWN:
-            if sel < (self.dropdownlistbox.GetItemCount() - 1):
-                self.dropdownlistbox.Select(sel + 1)
-                self._listItemVisible()
-            self._showDropDown()
-            skip = False
+        if KC == wx.WXK_RIGHT:
+            if len(self.GetValue()) < 1 and not visible:
+                if sel < (self.dropdownlistbox.GetItemCount() - 1):
+                    self.dropdownlistbox.Select(sel + 1)
+                    self._listItemVisible()
+                self._showDropDown()
+                skip = False
         elif KC == wx.WXK_UP:
-            if sel > 0:
-                self.dropdownlistbox.Select(sel - 1)
-                self._listItemVisible()
-            self._showDropDown()
-            skip = False
+            if visible:
+                if sel > 0:
+                    self.dropdownlistbox.Select(sel - 1)
+                    self._listItemVisible()
+                self._showDropDown()
+                skip = False
+            else:
+                self._historyItem -= 1
+                try:
+                    self.SetValue(self.GetItems()[self._historyItem])
+                except IndexError:
+                    self._historyItem += 1
+        elif KC == wx.WXK_DOWN:
+            if visible:
+                if sel < (self.dropdownlistbox.GetItemCount() - 1):
+                    self.dropdownlistbox.Select(sel + 1)
+                    self._listItemVisible()
+                self._showDropDown()
+                skip = False
+            else:
+                if self._historyItem < -1:
+                    self._historyItem += 1
+                    self.SetValue(self.GetItems()[self._historyItem])
         
         if visible:
             if event.GetKeyCode() == wx.WXK_RETURN: