EditText1.Tag = EditText2
EditText2.Tag = EditText3
EditText3.Tag = EditText4
EditText4.Tag = EditText1
Sub EditText_EnterPressed
Dim currentView, nextView As View
currentView = Sender
nextView = currentView.Tag
nextView.RequestFocus
End Sub
- Set ForceDone of all the EditTexts to True.
- Set their EventName to EditText
Use the tag property to set the next EditText:
B4X:EditText1.Tag = EditText2 EditText2.Tag = EditText3 EditText3.Tag = EditText4 EditText4.Tag = EditText1 Sub EditText_EnterPressed Dim currentView, nextView As View currentView = Sender nextView = currentView.Tag nextView.RequestFocus End Sub
In this case you don't need to specify the Tag property in the Designer because you change it afterwards in the code.
I suppose that the Tag properties set in the Designer is considered as Strings and not as objects thats the reason why you need to define them in the code.
Best regards.
- Set ForceDone of all the EditTexts to True.
- Set their EventName to EditText
Use the tag property to set the next EditText:
B4X:EditText1.Tag = EditText2 EditText2.Tag = EditText3 EditText3.Tag = EditText4 EditText4.Tag = EditText1 Sub EditText_EnterPressed Dim currentView, nextView As View currentView = Sender nextView = currentView.Tag nextView.RequestFocus End Sub
Type sETInfo(FieldName As String, Field As EditText, NextTab As EditText)
' Type sETInfo(FieldName As String, Field As EditText, NextTab As EditText) ' <-- this is defined in global section just copied here
Sub SetTabOrder(FieldName As String, Field As EditText, NextTab As EditText)
Dim ETInfo As sETInfo
ETInfo.Initialize
ETInfo.FieldName = FieldName
ETInfo.Field = Field
ETInfo.NextTab = NextTab
Field.Tag = ETInfo
End Sub
Sub SetupFields
mFWC_FWName.Color = Colors.White
mFWC_StartsAtGame.Color = Colors.White
mFWC_NumberOfGames.Color = Colors.White
mFWC_Cost.Color = Colors.White
mFWC_HandicapBase.Color = Colors.White
mFWC_HandicapPercent.Color = Colors.White
mFWC_BonusPins.Color = Colors.White
'-------------------------------------------------------
' Set TabOrder
'-------------------------------------------------------
SetTabOrder("mFWC_FWName", mFWC_FWName, mFWC_StartsAtGame)
SetTabOrder("mFWC_StartsAtGame", mFWC_StartsAtGame, mFWC_NumberOfGames)
SetTabOrder("mFWC_NumberOfGames", mFWC_NumberOfGames, mFWC_Cost)
SetTabOrder("mFWC_Cost", mFWC_Cost, mFWC_HandicapBase)
SetTabOrder("mFWC_HandicapBase", mFWC_HandicapBase, mFWC_HandicapPercent)
SetTabOrder("mFWC_HandicapPercent", mFWC_HandicapPercent, mFWC_BonusPins)
SetTabOrder("mFWC_BonusPins", mFWC_BonusPins, mFWC_FWName)
End Sub
Sub mFWC_EditText_EnterPressed
Dim ETInfo As sETInfo
Dim currentView As View
Dim nextField As EditText
Dim currentField As EditText
Dim Value As Int
currentField = Sender
ETInfo.Initialize
ETInfo = currentField.Tag
currentField = ETInfo.Field
nextField = ETInfo.NextTab
Log("1)FWData:" &gFWCreateData.FrameworkName &" Field:" &mFWC_FWName.Text)
Select ETInfo.FieldName
Case "mFWC_StartsAtGame"
Log("2)FWData:" &gFWCreateData.FrameworkName &" Field:" &mFWC_FWName.Text)
Value = cGenFuncs.StrToInt(currentField.Text)
If Value < 0 OR Value > 4 Then
cGenFuncs.MessageBox("Range is 1 to 4", "Invalid Starting Game")
currentField.RequestFocus
Return
End If
Case "mFWC_NumberOfGames"
Log("3)FWData:" &gFWCreateData.FrameworkName &" Field:" &mFWC_FWName.Text)
Value = cGenFuncs.StrToInt(currentField.Text)
If Value < 0 OR Value > 4 Then
cGenFuncs.MessageBox("Range is 1 to 4", "Invalid Starting Game")
currentField.RequestFocus
Return
Else
Dim StartGame As Int = cGenFuncs.StrToInt(mFWC_StartsAtGame.Text)
If StartGame + Value > 4 Then
cGenFuncs.MessageBox("Starting game plus number of games MUST be less than 4", "Invalid Number of Games")
currentField.RequestFocus
Return
End If
End If
Case "mFWC_Cost"
Log("4)FWData:" &gFWCreateData.FrameworkName &" Field:" &mFWC_FWName.Text)
currentField.Text = cGenFuncs.MoneyToStr(cGenFuncs.StrToMoney(currentField.Text))
Case "mFWC_HandicapBase"
Log("5)FWData:" &gFWCreateData.FrameworkName &" Field:" &mFWC_FWName.Text)
Value = cGenFuncs.StrToInt(currentField.Text)
If Value < 0 OR Value > 300 Then
cGenFuncs.MessageBox("Range is 0 to 300", "Invalid Handicap Base")
currentField.RequestFocus
Return
End If
Case "mFWC_HandicapPercent"
Log("6)FWData:" &gFWCreateData.FrameworkName &" Field:" &mFWC_FWName.Text)
Value = cGenFuncs.StrToInt(currentField.Text)
If Value < 0 OR Value > 100 Then
cGenFuncs.MessageBox("Range is 1 to 100", "Invalid Handicap Percentage")
currentField.RequestFocus
Return
End If
Case "mFWC_BonusPins"
Log("7)FWData:" &gFWCreateData.FrameworkName &" Field:" &mFWC_FWName.Text)
Value = cGenFuncs.StrToInt(currentField.Text)
If Value > 10 Then
cGenFuncs.MessageBox("Range is 0 to 10", "Invalid Bonus Pins")
currentField.RequestFocus
Return
End If
Case Else
Log("7a)FWData:" &gFWCreateData.FrameworkName &" Field:" &mFWC_FWName.Text)
End Select
Log("8)FWData:" &gFWCreateData.FrameworkName &" Field:" &mFWC_FWName.Text)
Do While nextField.Enabled = False
Log("9)FWData:" &gFWCreateData.FrameworkName &" Field:" &mFWC_FWName.Text)
ETInfo = nextField.Tag
nextField = ETInfo.NextTab
Loop
Log("A)FWData:" &gFWCreateData.FrameworkName &" Field:" &mFWC_FWName.Text)
nextField.RequestFocus
End Sub
Sub mFWC_EditText_TextChanged (Old As String, New As String)
Log("Old:" &Old &" New:" &New)
End Sub
Log("-----------------------------------------------------")
Log("EnterPressed")
Log("-----------------------------------------------------")
Log(" mFWC_FWName:" &mFWC_FWName.Text)
Log(" mFWC_StartsAtGame:" &mFWC_StartsAtGame.Text)
Log(" mFWC_NumberOfGames:" &mFWC_NumberOfGames.Text)
Log(" mFWC_Cost:" &mFWC_Cost.Text)
Log(" mFWC_HandicapBase:" &mFWC_HandicapBase.Text)
Log("mFWC_HandicapPercent:" &mFWC_HandicapPercent.Text)
Log(" mFWC_BonusPins:" &mFWC_BonusPins.Text)
Log("-----------------------------------------------------")
Log("Old:" &Old &" New:" &New)
Dim gLastFocus As EditText
Sub mFWC_EditText_FocusChanged(HasFocus As Boolean)
If HasFocus Then gLastFocus = Sender
End Sub
gLastFocus.Initialize("EditText")
gLastFocus = mFWC_FWName
Just what I was looking for. What is the hierchy pane?if you use the designer to build your forms then you can arrange your views to receive focus in the hierchy pane. drag them in the order youd like to 'tab' through. The first one receives focus when your layout is displayed.
Cheers!