Using B4A 3.20, I'm trying to get my app to move to another view (from one EditText named edtOSGBGridRef2 to another EditText named edtOSGBGridRef3, both of them being for Decimal Figures). However, I can see that the runtime path with a 4 digit number being entered (i.e. it passes the length validation shown below) goes through both the Msgbox's shown below but the RequestFocus command does not work since the focus moves to another view:
B4X:
Msgbox("Enter", "GR2")
If edtOSGBGridRef2.Text.Trim.Length < 2 OR edtOSGBGridRef2.Text.Trim.Length > 5 Then
DisplayMsgbox("OSGB Grid Reference Across must be 2 to 5 digits", "Incorrect OSGB Grid Reference Across")
Else
Msgbox("Valid", "GR2")
edtOSGBGridRef3.RequestFocus
End If
What am I doing wrong?
PS I have other RequestFocus commands after other EditText views' values are entered & none of them work.
I looked at the document. I didn't understand it. However, I did wonder if it would be possible to test if a view is focusable in B4A. I don't understand why the above edtOSGBGridRef2 view should not be focusable.
When I didn't have the Msgbox's, it didn't work. I put them in to see what was happening.
I just looked at the Accessibility Library: the documentation refers to a direction controller which would presumably have up, down, left & right physical arrow keys. I only intend to use this app on standard phones & tablets (i.e. without arrow keys). So Idon't think that this library is of use here. At runtime when the user moves to either of the EditText views which are Decimal Figures, a software keypad pops up with numeric digits, signs, decimal point and with 'Next'. The user presses 'Next' (which is equivalent to Enter) & the above edtOSGBGridRef2_Enter sub is executed.
I've tried it & it worked: what strange spelling (for the Accessiblty thingy)! I did the same for SetNextFocusUp, SetFocusLeft & SetFocusRight. What a lot of coding for what seems to be a very simple thing! I just noticed (in the B4A User's Guide) that the IME library command of ShowKeyboard almost does what I want: it gives focus to the specified EditText view (which I don't want to do for all my views) & shows the keyboard.
As you mentioned, unless your user has a Dpad, SetfocusLeft and SetFocusRight will probably never be called. I don't know if a hardware keyboard will call SetNextFocusUp for a shift Tab key combination, I've not tried it.