]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
1) added hotkey's to grid forms
authorewt <ewt>
Thu, 26 Aug 1999 23:18:06 +0000 (23:18 +0000)
committerewt <ewt>
Thu, 26 Aug 1999 23:18:06 +0000 (23:18 +0000)
2) set listbox position by key, not index

snack.py
snackmodule.c

index 90dc3ec58bf398429e4d1c9ec217f4d59757dd76..03927765c784be816777f5cffa6b642e74f6bff2 100644 (file)
--- a/snack.py
+++ b/snack.py
@@ -82,8 +82,8 @@ class Listbox(Widget):
     def current(self):
        return self.key2item[self.w.listboxGetCurrent()]
 
-    def setCurrent(self, index):
-       self.w.listboxSetCurrent(index)
+    def setCurrent(self, item):
+       self.w.listboxSetCurrent(self.item2key[item])
 
     def __init__(self, height, scroll = 0, returnExit = 0, width = 0):
        self.w = _snack.listbox(height, scroll, returnExit)
@@ -372,6 +372,9 @@ class GridForm(Grid):
        self.screen.popWindow()
        return result
 
+    def addHotKey(self, keyname):
+       self.form.addHotKey(keyname)
+
     def create(self):
        if not self.form_created:
            self.place(1,1)
@@ -438,6 +441,11 @@ def ListboxChoiceWindow(screen, title, text, items,
            text = item
            key = count
 
+       if (count == default):
+           default = key
+       elif (count == item):
+           default = key
+
        l.append(text, key)
        count = count + 1
 
index 9999fb09cf3223dfd2fd6d79a9e3a812f02c02d9..d0be0712699ef27a2b51526d2577a0313e92e9a2 100644 (file)
@@ -861,7 +861,7 @@ static PyObject * widgetListboxSet(snackWidget * s, PyObject * args) {
     if (!PyArg_ParseTuple(args, "i", &index))
        return NULL;
 
-    newtListboxSetCurrent(s->co, index);
+    newtListboxSetCurrentByKey(s->co, index);
 
     Py_INCREF(Py_None);
     return Py_None;