Hi guys,
i want to fire the textchange-Event from a customview but i don't know how.
Can anybody help me.
Here my Code for the customview with label
<code>
'Events declaration
#Event: TextChanged
#Event: EnterPressed
'Class module
Sub Class_Globals
Private mTarget As Object
Private mEventName As String
Private et1 As EditText
Private lbl1 As Label
Private basePanel As Panel
Private colNormal, colLabel, colText, sizeTxt1, sizeTxt2, txtGravity As Int
Private cTxt As String
Private CanvasRectangle As Canvas
Private Rect1 As Rect
Private timerET As Timer
Private Old As String
Public ipDecimal, ipNone, ipNumbers, ipPhone, ipText As Int
End Sub
Public Sub Initialize (TargetModule As Object, EventName As String)
mTarget = TargetModule
mEventName = EventName
timerET.Initialize("timerET", 300)
End Sub
Public Sub DesignerCreateView(Base As Panel, lbl As Label, Props As Map)
basePanel.Initialize("")
basePanel = Base
lbl1.Initialize("")
et1.Initialize(mEventName)
ipDecimal = et1.INPUT_TYPE_DECIMAL_NUMBERS
ipNone = et1.INPUT_TYPE_NONE
ipNumbers = et1.INPUT_TYPE_NUMBERS
ipPhone = et1.INPUT_TYPE_PHONE
ipText = et1.INPUT_TYPE_TEXT
'create a button and add it to the Base panel.
Base.AddView(lbl1, 33, 4, Base.Width - 37 , 40)
Base.AddView(et1, 8, 46, Base.Width - 12, Base.Height - 40 )
Base.Height = Base.Height + 4
Base.Width = Base.Width + 4
CanvasRectangle.Initialize(Base)
Rect1.Initialize(0,0, Base.Width, Base.Height)
CanvasRectangle.DrawRect(Rect1, Colors.DarkGray, False, 3dip)
colLabel = Colors.DarkGray
colText = Colors.Black
colNormal = Colors.ARGB(255,255,255,255)
lbl.Color = colNormal
txtGravity = lbl.Gravity
lbl1.TextColor = colLabel
lbl1.Color = colNormal
lbl1.Gravity = txtGravity
sizeTxt1 = lbl.TextSize
et1.TextSize = 14
et1.TextColor = colText
et1.Gravity = txtGravity
et1.Text = lbl.Text
et1.Tag = lbl.Tag
'et1.Typeface = lbl.Typeface
'et1.InputType = et1.INPUT_TYPE_TEXT
et1.RequestFocus
'et1.
'et1.Color = colNormal
'Add a transparent panel over the button.
'the panel will handle the touch event.
lbl1.BringToFront
et1.BringToFront
End Sub
Public Sub setText(Text As String)
et1.Text = Text
End Sub
Public Sub getText() As String
Return et1.Text
End Sub
Public Sub setTag(Tag As String)
et1.Tag = Tag
End Sub
Public Sub getTag() As String
Return et1.Tag
End Sub
Public Sub getEditTextObject() As Object
Return et1
End Sub
Public Sub setLabelText(Text As String)
lbl1.Text = Text
End Sub
Public Sub getLabelText() As String
Return lbl1.Text
End Sub
Public Sub setTextColor(TextColor As Int)
colText = TextColor
et1.TextColor = colText
End Sub
Public Sub setLabelTextColor(TextColor As Int)
colLabel = TextColor
lbl1.TextColor = colLabel
End Sub
Public Sub setTextSize(TextSize As Int)
sizeTxt2 = TextSize
et1.TextSize = sizeTxt2
End Sub
Public Sub setLabelTextSize(TextSize As Int)
sizeTxt1 = TextSize
lbl1.TextSize = sizeTxt1
End Sub
Public Sub setGravity(TextGravity As Int)
txtGravity = TextGravity
lbl1.Gravity = txtGravity
et1.Gravity = txtGravity
End Sub
Public Sub setColorNormal(colorNormal As Int)
colNormal = colorNormal
End Sub
Public Sub setBringToFront()
basePanel.BringToFront
End Sub
Public Sub setInputType(InputType As Int)
et1.InputType = InputType
End Sub
Public Sub getInputType() As Int
Return et1.InputType
End Sub
Public Sub setHeight(iSize As Int)
Private iPanelBakWidth, etWidth As Int
iPanelBakWidth = basePanel.Width
etWidth = et1.Width
basePanel.RemoveAllViews
basePanel.AddView(lbl1, 33, 4, basePanel.Width - 37 , 40)
If iSize > 98 Then
basePanel.AddView(et1, 8, 46, etWidth, iSize - 44 )
basePanel.Height = iSize
Else
basePanel.AddView(et1, 8, 46, etWidth, 98 - 44 )
basePanel.Height = 98dip
End If
basePanel.Width = iPanelBakWidth
CanvasRectangle.Initialize(basePanel)
Rect1.Initialize(0,0, basePanel.Width, basePanel.Height)
CanvasRectangle.DrawRect(Rect1, Colors.DarkGray, False, 3dip)
End Sub
Public Sub setWidth(iSize As Int)
Private iPanelBakHeight, etHeight As Int
iPanelBakHeight = basePanel.Height
etHeight = et1.Height
basePanel.RemoveAllViews
basePanel.AddView(lbl1, 33, 4, iSize - 37 , 40)
basePanel.AddView(et1, 8, 46, iSize - 16, etHeight)
basePanel.Width = iSize
basePanel.Height = iPanelBakHeight
CanvasRectangle.Initialize(basePanel)
Rect1.Initialize(0,0, basePanel.Width, basePanel.Height)
CanvasRectangle.DrawRect(Rect1, Colors.DarkGray, False, 3dip)
End Sub
Public Sub setTop(Top As Int)
basePanel.Top = Top
End Sub
Public Sub getTop() As Int
Return basePanel.Top
End Sub
Public Sub setLeft(Left As Int)
basePanel.Left = Left
End Sub
Public Sub getLeft() As Int
Return basePanel.Left
End Sub
Public Sub setWrap(Value As Boolean)
et1.Wrap = Value
End Sub
Public Sub setHorizontalCenter(Position As Int)
basePanel.SetLayout(Position-basePanel.width/2, basePanel.Top, basePanel.Width, basePanel.Height)
End Sub
Private Sub TimerET_Tick
If Old <> et1.Text Then
'timerET.Enabled = False
'raise the event
CallSub3(mTarget, mEventName & "_" & "TextChanged", Old, et1.Text)
Old = et1.text
End If
End Sub
</code>
Best regards from Germany
Roland
i want to fire the textchange-Event from a customview but i don't know how.
Can anybody help me.
Here my Code for the customview with label
<code>
'Events declaration
#Event: TextChanged
#Event: EnterPressed
'Class module
Sub Class_Globals
Private mTarget As Object
Private mEventName As String
Private et1 As EditText
Private lbl1 As Label
Private basePanel As Panel
Private colNormal, colLabel, colText, sizeTxt1, sizeTxt2, txtGravity As Int
Private cTxt As String
Private CanvasRectangle As Canvas
Private Rect1 As Rect
Private timerET As Timer
Private Old As String
Public ipDecimal, ipNone, ipNumbers, ipPhone, ipText As Int
End Sub
Public Sub Initialize (TargetModule As Object, EventName As String)
mTarget = TargetModule
mEventName = EventName
timerET.Initialize("timerET", 300)
End Sub
Public Sub DesignerCreateView(Base As Panel, lbl As Label, Props As Map)
basePanel.Initialize("")
basePanel = Base
lbl1.Initialize("")
et1.Initialize(mEventName)
ipDecimal = et1.INPUT_TYPE_DECIMAL_NUMBERS
ipNone = et1.INPUT_TYPE_NONE
ipNumbers = et1.INPUT_TYPE_NUMBERS
ipPhone = et1.INPUT_TYPE_PHONE
ipText = et1.INPUT_TYPE_TEXT
'create a button and add it to the Base panel.
Base.AddView(lbl1, 33, 4, Base.Width - 37 , 40)
Base.AddView(et1, 8, 46, Base.Width - 12, Base.Height - 40 )
Base.Height = Base.Height + 4
Base.Width = Base.Width + 4
CanvasRectangle.Initialize(Base)
Rect1.Initialize(0,0, Base.Width, Base.Height)
CanvasRectangle.DrawRect(Rect1, Colors.DarkGray, False, 3dip)
colLabel = Colors.DarkGray
colText = Colors.Black
colNormal = Colors.ARGB(255,255,255,255)
lbl.Color = colNormal
txtGravity = lbl.Gravity
lbl1.TextColor = colLabel
lbl1.Color = colNormal
lbl1.Gravity = txtGravity
sizeTxt1 = lbl.TextSize
et1.TextSize = 14
et1.TextColor = colText
et1.Gravity = txtGravity
et1.Text = lbl.Text
et1.Tag = lbl.Tag
'et1.Typeface = lbl.Typeface
'et1.InputType = et1.INPUT_TYPE_TEXT
et1.RequestFocus
'et1.
'et1.Color = colNormal
'Add a transparent panel over the button.
'the panel will handle the touch event.
lbl1.BringToFront
et1.BringToFront
End Sub
Public Sub setText(Text As String)
et1.Text = Text
End Sub
Public Sub getText() As String
Return et1.Text
End Sub
Public Sub setTag(Tag As String)
et1.Tag = Tag
End Sub
Public Sub getTag() As String
Return et1.Tag
End Sub
Public Sub getEditTextObject() As Object
Return et1
End Sub
Public Sub setLabelText(Text As String)
lbl1.Text = Text
End Sub
Public Sub getLabelText() As String
Return lbl1.Text
End Sub
Public Sub setTextColor(TextColor As Int)
colText = TextColor
et1.TextColor = colText
End Sub
Public Sub setLabelTextColor(TextColor As Int)
colLabel = TextColor
lbl1.TextColor = colLabel
End Sub
Public Sub setTextSize(TextSize As Int)
sizeTxt2 = TextSize
et1.TextSize = sizeTxt2
End Sub
Public Sub setLabelTextSize(TextSize As Int)
sizeTxt1 = TextSize
lbl1.TextSize = sizeTxt1
End Sub
Public Sub setGravity(TextGravity As Int)
txtGravity = TextGravity
lbl1.Gravity = txtGravity
et1.Gravity = txtGravity
End Sub
Public Sub setColorNormal(colorNormal As Int)
colNormal = colorNormal
End Sub
Public Sub setBringToFront()
basePanel.BringToFront
End Sub
Public Sub setInputType(InputType As Int)
et1.InputType = InputType
End Sub
Public Sub getInputType() As Int
Return et1.InputType
End Sub
Public Sub setHeight(iSize As Int)
Private iPanelBakWidth, etWidth As Int
iPanelBakWidth = basePanel.Width
etWidth = et1.Width
basePanel.RemoveAllViews
basePanel.AddView(lbl1, 33, 4, basePanel.Width - 37 , 40)
If iSize > 98 Then
basePanel.AddView(et1, 8, 46, etWidth, iSize - 44 )
basePanel.Height = iSize
Else
basePanel.AddView(et1, 8, 46, etWidth, 98 - 44 )
basePanel.Height = 98dip
End If
basePanel.Width = iPanelBakWidth
CanvasRectangle.Initialize(basePanel)
Rect1.Initialize(0,0, basePanel.Width, basePanel.Height)
CanvasRectangle.DrawRect(Rect1, Colors.DarkGray, False, 3dip)
End Sub
Public Sub setWidth(iSize As Int)
Private iPanelBakHeight, etHeight As Int
iPanelBakHeight = basePanel.Height
etHeight = et1.Height
basePanel.RemoveAllViews
basePanel.AddView(lbl1, 33, 4, iSize - 37 , 40)
basePanel.AddView(et1, 8, 46, iSize - 16, etHeight)
basePanel.Width = iSize
basePanel.Height = iPanelBakHeight
CanvasRectangle.Initialize(basePanel)
Rect1.Initialize(0,0, basePanel.Width, basePanel.Height)
CanvasRectangle.DrawRect(Rect1, Colors.DarkGray, False, 3dip)
End Sub
Public Sub setTop(Top As Int)
basePanel.Top = Top
End Sub
Public Sub getTop() As Int
Return basePanel.Top
End Sub
Public Sub setLeft(Left As Int)
basePanel.Left = Left
End Sub
Public Sub getLeft() As Int
Return basePanel.Left
End Sub
Public Sub setWrap(Value As Boolean)
et1.Wrap = Value
End Sub
Public Sub setHorizontalCenter(Position As Int)
basePanel.SetLayout(Position-basePanel.width/2, basePanel.Top, basePanel.Width, basePanel.Height)
End Sub
Private Sub TimerET_Tick
If Old <> et1.Text Then
'timerET.Enabled = False
'raise the event
CallSub3(mTarget, mEventName & "_" & "TextChanged", Old, et1.Text)
Old = et1.text
End If
End Sub
</code>
Best regards from Germany
Roland