From: Mladen Horvat Date: Tue, 19 Apr 2011 09:54:22 +0000 (+0200) Subject: VirtualKeyBoard.py: add modified patch from Homey to allow keyboard inputs. refs... X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/d3c621480a77115a11fea85742ca85ae163c0d4b?hp=ff51af1d6d5547b8e8be08bd5660598e02a56eb6 VirtualKeyBoard.py: add modified patch from Homey to allow keyboard inputs. refs #750 --- diff --git a/lib/python/Screens/VirtualKeyBoard.py b/lib/python/Screens/VirtualKeyBoard.py index fc10a882..ebc347c6 100755 --- a/lib/python/Screens/VirtualKeyBoard.py +++ b/lib/python/Screens/VirtualKeyBoard.py @@ -1,4 +1,6 @@ # -*- coding: UTF-8 -*- +from enigma import eListboxPythonMultiContent, gFont, RT_HALIGN_CENTER, RT_VALIGN_CENTER, getPrevAsciiCode +from Screen import Screen from Components.Language import language from Components.ActionMap import ActionMap from Components.Sources.StaticText import StaticText @@ -6,8 +8,6 @@ from Components.Label import Label from Components.Pixmap import Pixmap from Components.MenuList import MenuList from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest -from enigma import eListboxPythonMultiContent, gFont, RT_HALIGN_CENTER, RT_VALIGN_CENTER -from Screen import Screen from Tools.Directories import resolveFilename, SCOPE_CURRENT_SKIN from Tools.LoadPixmap import LoadPixmap @@ -97,8 +97,9 @@ class VirtualKeyBoard(Screen): self["text"] = Label(self.text) self["list"] = VirtualKeyBoardList([]) - self["actions"] = ActionMap(["OkCancelActions", "WizardActions", "ColorActions"], + self["actions"] = ActionMap(["OkCancelActions", "WizardActions", "ColorActions", "KeyboardInputActions", "InputBoxActions", "InputAsciiActions"], { + "gotAsciiCode": self.keyGotAscii, "ok": self.okClicked, "cancel": self.exit, "left": self.left, @@ -107,9 +108,12 @@ class VirtualKeyBoard(Screen): "down": self.down, "red": self.backClicked, "green": self.ok, - "yellow": self.switchLang + "yellow": self.switchLang, + "deleteBackward": self.backClicked, + "back": self.exit }, -2) self.setLanq() + self.onExecBegin.append(self.setKeyboardModeAscii) self.onLayoutFinish.append(self.buildVirtualKeyBoard) def switchLang(self): @@ -362,3 +366,30 @@ class VirtualKeyBoard(Screen): def showActiveKey(self): self.buildVirtualKeyBoard(self.selectedKey) + + def inShiftKeyList(self,key): + for KeyList in self.shiftkeys_list: + for char in KeyList: + if char == key: + return True + return False + + def keyGotAscii(self): + char = str(unichr(getPrevAsciiCode()).encode('utf-8')) + if self.inShiftKeyList(char): + self.shiftMode = True + list = self.shiftkeys_list + else: + self.shiftMode = False + list = self.keys_list + + selkey = 0 + for keylist in list: + for key in keylist: + if key == char: + self.selectedKey = selkey + self.okClicked() + self.showActiveKey() + return + else: + selkey += 1