make switching of keyboard modes more consistent
authorAndreas Oberritter <obi@opendreambox.org>
Wed, 19 Jan 2011 23:59:45 +0000 (00:59 +0100)
committerAndreas Oberritter <obi@opendreambox.org>
Tue, 29 Mar 2011 13:48:37 +0000 (15:48 +0200)
lib/python/Screens/InputBox.py
lib/python/Screens/Screen.py

index 61ce356..914ab2b 100644 (file)
@@ -41,9 +41,11 @@ class InputBox(Screen):
                        "9": self.keyNumberGlobal,
                        "0": self.keyNumberGlobal
                }, -1)
                        "9": self.keyNumberGlobal,
                        "0": self.keyNumberGlobal
                }, -1)
+
                if self["input"].type == Input.TEXT:
                if self["input"].type == Input.TEXT:
-                       rcinput = eRCInput.getInstance()
-                       rcinput.setKeyboardMode(rcinput.kmAscii)
+                       self.onShow.append(self.setKeyboardModeAscii);
+               else:
+                       self.onShow.append(self.setKeyboardModeNone);
 
        def gotAsciiCode(self):
                self["input"].handleAscii(getPrevAsciiCode())
 
        def gotAsciiCode(self):
                self["input"].handleAscii(getPrevAsciiCode())
@@ -61,13 +63,9 @@ class InputBox(Screen):
                self["input"].delete()
 
        def go(self):
                self["input"].delete()
 
        def go(self):
-               rcinput = eRCInput.getInstance()
-               rcinput.setKeyboardMode(rcinput.kmNone)
                self.close(self["input"].getText())
 
        def cancel(self):
                self.close(self["input"].getText())
 
        def cancel(self):
-               rcinput = eRCInput.getInstance()
-               rcinput.setKeyboardMode(rcinput.kmNone)
                self.close(None)
 
        def keyHome(self):
                self.close(None)
 
        def keyHome(self):
@@ -142,19 +140,13 @@ class PinInput(InputBox):
                                pass
        
        def closePinWrong(self, *args):
                                pass
        
        def closePinWrong(self, *args):
-               rcinput = eRCInput.getInstance()
-               rcinput.setKeyboardMode(rcinput.kmNone)
                print "args:", args
                self.close(False)
                
        def closePinCorrect(self, *args):
                print "args:", args
                self.close(False)
                
        def closePinCorrect(self, *args):
-               rcinput = eRCInput.getInstance()
-               rcinput.setKeyboardMode(rcinput.kmNone)
                self.close(True)
                
        def closePinCancel(self, *args):
                self.close(True)
                
        def closePinCancel(self, *args):
-               rcinput = eRCInput.getInstance()
-               rcinput.setKeyboardMode(rcinput.kmNone)
                self.close(None)
                        
        def cancel(self):
                self.close(None)
                        
        def cancel(self):
index f0bf773..fa6999a 100644 (file)
@@ -6,6 +6,8 @@ profile("LOAD:Source")
 from Components.Sources.Source import Source
 profile("LOAD:GUIComponent")
 from Components.GUIComponent import GUIComponent
 from Components.Sources.Source import Source
 profile("LOAD:GUIComponent")
 from Components.GUIComponent import GUIComponent
+profile("LOAD:eRCInput")
+from enigma import eRCInput
 
 class Screen(dict, GUISkin):
 
 
 class Screen(dict, GUISkin):
 
@@ -47,6 +49,27 @@ class Screen(dict, GUISkin):
                # don't care about having or not having focus.
                self.stand_alone = False
 
                # don't care about having or not having focus.
                self.stand_alone = False
 
+               self.onShow.append(self.saveKeyboardMode);
+               self.onHide.append(self.restoreKeyboardMode)
+               self.keyboardMode = None
+
+       def saveKeyboardMode(self):
+               rcinput = eRCInput.getInstance()
+               self.keyboardMode = rcinput.getKeyboardMode()
+
+       def setKeyboardModeAscii(self):
+               rcinput = eRCInput.getInstance()
+               rcinput.setKeyboardMode(rcinput.kmAscii)
+
+       def setKeyboardModeNone(self):
+               rcinput = eRCInput.getInstance()
+               rcinput.setKeyboardMode(rcinput.kmNone)
+
+       def restoreKeyboardMode(self):
+               rcinput = eRCInput.getInstance()
+               if self.keyboardMode is not None:
+                       rcinput.setKeyboardMode(self.keyboardMode)
+
        def execBegin(self):
                self.active_components = [ ]
                if self.close_on_next_exec is not None:
        def execBegin(self):
                self.active_components = [ ]
                if self.close_on_next_exec is not None: