hi, i try to create a custom view (incrementing text in a label with a timer)
I managed to make the text appear thanks to my start function. But as my Start function has the sleep command into a loop, i can not find the way to catch the end of my Start function.
customModuleCode :
and in my main module i try to do this :
But i need to catch the end of LabelAuto1.start for do the next instruction...
I managed to make the text appear thanks to my start function. But as my Start function has the sleep command into a loop, i can not find the way to catch the end of my Start function.
customModuleCode :
B4X:
'Custom View class
#Event: ExampleEvent (Value As Int)
#Event: Click
#DesignerProperty: key: Vitesse1, DisplayName: Vitesse1, FieldType: Int, DefaultValue: 70
#DesignerProperty: key: Vitesse2, DisplayName: Vitesse2, FieldType: Int, DefaultValue: 50
#DesignerProperty: key: Vitesse3, DisplayName: Vitesse3, FieldType: Int, DefaultValue: 30
Sub Class_Globals
Private mEventName As String 'ignore
Private mCallBack As Object 'ignore
Private mBase As Panel
Private mLbl As Label
Private mText As String
Private Const DefaultColorConstant As Int = -984833 'ignore
Private xui As XUI
Private mVitesse,vitesse1,vitesse2,vitesse3 As Int
End Sub
Public Sub Initialize (Callback As Object, EventName As String)
mEventName = EventName
mCallBack = Callback
End Sub
Public Sub DesignerCreateView (Base As Panel, Lbl As Label, Props As Map)
For i = 0 To Props.Size-1
Log(Props.GetKeyAt(i) & " = " & Props.GetValueAt(i))
Next
mBase = Base
mLbl.Initialize("mLbl")
mBase.AddView(mLbl, 0, 0, mBase.Width, mBase.Height)
mLbl.Background = Lbl.Background
mLbl.Gravity= Gravity.CENTER
mLbl.Enabled=Lbl.Enabled
mLbl.Tag=Lbl.Tag
mLbl.Text = ""
mLbl.TextColor = Lbl.TextColor
mLbl.TextSize=Lbl.TextSize
mLbl.Visible=Lbl.Visible
vitesse1=Props.Get("Vitesse1")
vitesse2=Props.Get("Vitesse2")
vitesse3=Props.Get("Vitesse3")
mText = Lbl.Text
End Sub
Public Sub GetBase As Panel
Return mBase
End Sub
Public Sub Start
Log("Start")
If mVitesse>0 Then Return
mVitesse=vitesse1
mLbl.Text=""
For i = 0 To mText.Length
mLbl.Text=mText.SubString2(0,i)
Sleep(mVitesse)
Next
mVitesse=0
End Sub
Public Sub Text(str As String)
mText = str
End Sub
Private Sub mLbl_Click
If mVitesse=vitesse1 And vitesse2<> 0 Then
mVitesse=vitesse2
Else If mVitesse=vitesse2 And vitesse3 <> 0 Then
mVitesse=vitesse3
End If
CallSub(mCallBack,mEventName & "_Click")
End Sub
and in my main module i try to do this :
B4X:
Sub LabelAuto1_Click
LAbelAuto1.Start
LAbelAuto1.Text("Fin du premier test Fin du premier test Fin du premier test Fin du premier test")
LAbelAuto1.Start
Log("ok")
End Sub
But i need to catch the end of LabelAuto1.start for do the next instruction...