I did not backup my souce file and now it's lost.
Now I am trying to rewrite it but when I get to the point of "TextBox.BingToFront" then try "TextBox2.Focus" I dont get focus.
I get TextBox.2 to the front but I have to click in texbox feild to get focus.
Now I am trying to rewrite it but when I get to the point of "TextBox.BingToFront" then try "TextBox2.Focus" I dont get focus.
I get TextBox.2 to the front but I have to click in texbox feild to get focus.
B4X:
Sub Globals
'Declare the global variables here.
Dim focused 'saves the focused textbox name
End Sub
Sub App_Start
Form1.Show
ImageButtonExit.BringToFront
flib.new1("form1",B4PObject(1))
flib.fullscreen(CPPC)
End Sub
Sub InitializeControls
alTextBox.Add("textbox1")
alTextBox.Add("textbox2")
alTextBox.Add("textbox3")
For i = 1 To 11 'Adds the click event to all regular number buttons.
AddEvent("Button" & i, Click, "Numbers_Click")
Next
For i = 0 To altextbox.Count -1'Adds the gotfocus event to all textboxes.
AddEvent(altextbox.Item(i),GotFocus, "TextBoxes_GotFocus")
Next
focused = altextbox.Item(0)
Control(focused).Focus
End Sub
Sub TextBoxes_GotFocus
focused = Sender.Name
End Sub
Sub Numbers_Click 'Handles 0-9 and '.'
st = Control(focused).SelectionStart
txt = Control(focused).Text
If Sender.Text = "." Then 'checks for multiple periods.
i = StrIndexOf(txt,".",0)
If i = -1 Then Goto ok
sl = Control(focused).SelectionLength
If sl > 0 Then
If StrIndexOf(SubString(txt,st,sl),".",0) > -1 Then Goto ok
End If
Control(focused).Focus
Return
End If
ok:
If Control(focused).SelectionLength > 0 Then
Control(focused).Text = StrRemove(txt,st, Control(focused).SelectionLength)
End If
Control(focused).Text = StrInsert(Control(focused).Text,st,Sender.Text)
Control(focused).SelectionLength = 0
Control(focused).SelectionStart = st + 1
Control(focused).Focus
End Sub
Sub ButtonBS_Click 'Backspace
st = Control(focused).SelectionStart
txt = Control(focused).Text
If Control(focused).SelectionLength > 0 Then
Control(focused).Text = StrRemove(txt,st, Control(focused).SelectionLength)
Control(focused).SelectionStart = st
Else If st > 0 Then
Control(focused).Text = StrRemove(txt,st-1,1)
Control(focused).SelectionStart = st - 1
End If
Control(focused).SelectionLength = 0
Control(focused).Focus
End Sub
Sub ImageButtonExit_Click
Form1.Close
End Sub
Sub ImageButtonExitNum_Click
PanelSum.BringToFront
ImageButtonExit.BringToFront
PanelBGH.BringToFront
PanelFGH.BringToFront
TextBox1.Text=""
TextBox2.Text=""
TextBox3.Text=""
End Sub
Sub ButtonPPH_Click
PanelBGH.BringToFront
PanelFGH.BringToFront
ButtonEnterPPH.BringToFront
TextBox1.BringToFront 'TextBoxes 1,2 and 3 are on form1
TextBox1.Focus
PanelNumPad.BringToFront
ImageButtonExitNum.BringToFront
InitializeControls
End Sub
Sub ButtonLayer_Click
PanelBGH.BringToFront
PanelFGH.BringToFront
ButtonEnterLayer.BringToFront
TextBox2.BringToFront
TextBox2.Focus
PanelNumPad.BringToFront
ImageButtonExitNum.BringToFront
InitializeControls
End Sub
Sub ButtonDos_Click
PanelBGH.BringToFront
PanelFGH.BringToFront
TextBox3.BringToFront
TextBox3.Focus
PanelBGF.BringToFront
PanelFGF.BringToFront
PanelNumPad.BringToFront
ImageButtonExitNum.BringToFront
InitializeControls
End Sub
Sub ButtonEnterPPH_Click
ButtonPPH.Text=TextBox1.Text
PanelSum.BringToFront
ImageButtonExit.BringToFront
PanelBGH.BringToFront
PanelFGH.BringToFront
TextBox1.Text=""
TextBox2.Text=""
TextBox3.Text=""
End Sub
Sub ButtonEnterLayer_Click
ButtonLayer.Text=TextBox2.Text
PanelSum.BringToFront
ImageButtonExit.BringToFront
PanelBGH.BringToFront
PanelFGH.BringToFront
TextBox1.Text=""
TextBox2.Text=""
TextBox3.Text=""
End Sub