toolkit: initial checkin
[enigma2-plugins.git] / moviesearch / src / NTIVirtualKeyBoard.py
1 from Tools.NumericalTextInput import NumericalTextInput
2 from Screens.VirtualKeyBoard import VirtualKeyBoard
3 from Components.ActionMap import NumberActionMap
4
5 class NTIVirtualKeyBoard(VirtualKeyBoard, NumericalTextInput):
6         def __init__(self, session, **kwargs):
7                 VirtualKeyBoard.__init__(self, session, **kwargs)
8                 NumericalTextInput.__init__(self, nextFunc = self.nextFunc)
9
10                 self.skinName = "VirtualKeyBoard"
11
12                 self["NumberActions"] = NumberActionMap(["NumberActions"],
13                 {
14                         "1": self.keyNumberGlobal,
15                         "2": self.keyNumberGlobal,
16                         "3": self.keyNumberGlobal,
17                         "4": self.keyNumberGlobal,
18                         "5": self.keyNumberGlobal,
19                         "6": self.keyNumberGlobal,
20                         "7": self.keyNumberGlobal,
21                         "8": self.keyNumberGlobal,
22                         "9": self.keyNumberGlobal,
23                         "0": self.keyNumberGlobal
24                 })
25
26                 self.editing = False
27
28         def backClicked(self):
29                 self.nextKey()
30                 self.editing = False
31                 self["text"].setMarkedPos(-1)
32                 VirtualKeyBoard.backClicked(self)
33
34         def okClicked(self):
35                 self.nextKey()
36                 self.editing = False
37                 self["text"].setMarkedPos(-1)
38                 VirtualKeyBoard.okClicked(self)
39
40         def keyNumberGlobal(self, number):
41                 unichar = self.getKey(number)
42                 if not self.editing:
43                         self.text = self["text"].getText()
44                         self.editing = True
45                         self["text"].setMarkedPos(len(self.text))
46                 self["text"].setText(self.text + unichar.encode('utf-8', 'ignore'))
47
48         def nextFunc(self):
49                 self.text = self["text"].getText()
50                 self.editing = False
51                 self["text"].setMarkedPos(-1)
52