allow selection of menu entries with numbers. Patch by Moritz Venn (enigma2_enable_nu...
authorFelix Domke <tmbinc@elitedvb.net>
Sat, 20 Oct 2007 07:20:08 +0000 (07:20 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Sat, 20 Oct 2007 07:20:08 +0000 (07:20 +0000)
lib/python/Screens/Menu.py

index bba6404..22aee7d 100644 (file)
@@ -1,6 +1,6 @@
 from Screen import Screen
 from Components.Sources.List import List
 from Screen import Screen
 from Components.Sources.List import List
-from Components.ActionMap import ActionMap
+from Components.ActionMap import NumberActionMap
 from Components.Sources.StaticText import StaticText
 from Components.config import configfile
 from Components.PluginComponent import plugins
 from Components.Sources.StaticText import StaticText
 from Components.config import configfile
 from Components.PluginComponent import plugins
@@ -204,19 +204,37 @@ class Menu(Screen):
 
                self["menu"] = List(list)
 
 
                self["menu"] = List(list)
 
-               self["actions"] = ActionMap(["OkCancelActions", "MenuActions"], 
+               self["actions"] = NumberActionMap(["OkCancelActions", "MenuActions", "NumberActions"],
                        {
                                "ok": self.okbuttonClick,
                                "cancel": self.closeNonRecursive,
                        {
                                "ok": self.okbuttonClick,
                                "cancel": self.closeNonRecursive,
-                               "menu": self.closeRecursive
+                               "menu": self.closeRecursive,
+                               "1": self.keyNumberGlobal,
+                               "2": self.keyNumberGlobal,
+                               "3": self.keyNumberGlobal,
+                               "4": self.keyNumberGlobal,
+                               "5": self.keyNumberGlobal,
+                               "6": self.keyNumberGlobal,
+                               "7": self.keyNumberGlobal,
+                               "8": self.keyNumberGlobal,
+                               "9": self.keyNumberGlobal
                        })
                        })
-               
+
                a = parent.getAttribute("title").encode("UTF-8") or None
                if a is None:
                        a = _(parent.getAttribute("text").encode("UTF-8"))
                self["title"] = StaticText(a)
                self.menu_title = a
 
                a = parent.getAttribute("title").encode("UTF-8") or None
                if a is None:
                        a = _(parent.getAttribute("text").encode("UTF-8"))
                self["title"] = StaticText(a)
                self.menu_title = a
 
+       def keyNumberGlobal(self, number):
+               print "menu keyNumber:", number
+               # Calculate index
+               number -= 1
+
+               if len(self["menu"].list) > number:
+                       self["menu"].setIndex(number)
+                       self.okbuttonClick()
+
        def closeNonRecursive(self):
                self.close(False)
 
        def closeNonRecursive(self):
                self.close(False)