revert local change (just for testing)
[enigma2.git] / lib / python / Screens / ChoiceBox.py
index 60aa5e10452fd9fa75e0594021fc8fee807fc60a..ce8f9bf9680543453fa3337ff7e8d27e2cc4629c 100644 (file)
@@ -18,7 +18,7 @@ class ChoiceBox(Screen):
                if keys is None:
                        self.keys = [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "red", "green", "yellow", "blue" ] + (len(list) - 10) * [""]
                else:
-                       self.keys = keys
+                       self.keys = keys + (len(list) - len(keys)) * [""]
                        
                self.keymap = {}
                pos = 0
@@ -30,7 +30,7 @@ class ChoiceBox(Screen):
                        pos += 1
                self["list"] = ChoiceList(list = self.list, selection = selection)
                                
-               self["actions"] = NumberActionMap(["WizardActions", "InputActions", "ColorActions"], 
+               self["actions"] = NumberActionMap(["WizardActions", "InputActions", "ColorActions", "DirectionActions"], 
                {
                        "ok": self.go,
                        "back": self.cancel,
@@ -47,7 +47,9 @@ class ChoiceBox(Screen):
                        "red": self.keyRed,
                        "green": self.keyGreen,
                        "yellow": self.keyYellow,
-                       "blue": self.keyBlue
+                       "blue": self.keyBlue,
+                       "up": self.up,
+                       "down": self.down
                }, -1)
                
        def keyLeft(self):
@@ -56,14 +58,31 @@ class ChoiceBox(Screen):
        def keyRight(self):
                pass
        
+       def up(self):
+               if len(self["list"].list) > 0:
+                       while 1:
+                               self["list"].instance.moveSelection(self["list"].instance.moveUp)
+                               if self["list"].l.getCurrentSelection()[0][0] != "--" or self["list"].l.getCurrentSelectionIndex() == 0:
+                                       break
+               
+       def down(self):
+               if len(self["list"].list) > 0:
+                       while 1:
+                               self["list"].instance.moveSelection(self["list"].instance.moveDown)
+                               if self["list"].l.getCurrentSelection()[0][0] != "--" or self["list"].l.getCurrentSelectionIndex() == len(self["list"].list) - 1:
+                                       break
+
+
        def keyNumberGlobal(self, number):
                print "pressed", number
                if self.keymap.has_key(str(number)):
                        self.close(self.keymap[str(number)])
                
        def go(self):
-               self.close(self["list"].l.getCurrentSelection()[0])
-               #self.close(self["input"].getText())
+               if len(self["list"].list) > 0:
+                       self.close(self["list"].l.getCurrentSelection()[0])
+               else:
+                       self.close(None)
 
        def keyRed(self):
                if self.keymap.has_key("red"):