better marking of current cursor in Components.Input
[vuplus_dvbapp] / lib / python / Components / Input.py
1 from HTMLComponent import *
2 from GUIComponent import *
3 from VariableText import *
4
5 from enigma import eLabel
6
7 from Tools.NumericalTextInput import NumericalTextInput
8
9 class Input(HTMLComponent, GUIComponent, VariableText):
10         def __init__(self, text=""):
11                 GUIComponent.__init__(self)
12                 VariableText.__init__(self)
13                 self.numericalTextInput = NumericalTextInput(self.right)
14                 self.currPos = 0
15                 self.text = text
16                 self.update()
17
18         def update(self):
19                 self.setMarkedPos(self.currPos)
20                 self.setText(self.text)
21                 #self.setText(self.text[0:self.currPos] + "_" + self.text[self.currPos] + "_" + self.text[self.currPos + 1:])
22
23         
24         def createWidget(self, parent):
25                 return eLabel(parent, self.currPos)
26         
27         def getSize(self):
28                 s = self.instance.calculateSize()
29                 return (s.width(), s.height())
30         
31         def right(self):
32                 self.currPos += 1
33                 if self.currPos == len(self.text):
34                         self.text = self.text + " "
35                 self.update()
36                 
37         def left(self):
38                 self.currPos -= 1
39                 self.update()
40                 
41         def number(self, number):
42                 self.text = self.text[0:self.currPos] + self.numericalTextInput.getKey(number) + self.text[self.currPos + 1:]
43                 self.update()
44
45         def show(self):
46                 self.instance.show()
47
48         def hide(self):
49                 self.instance.hide()