Android Question Simulate focus, enter, move to other view, by code.

vecino

Well-Known Member
Licensed User
Longtime User
Hi, I have several edittext that do several processes on focus and exit. Finally there is an accept button.
The problem is that some users don't go from data to data but go directly to the save button.
My question is if it is possible to simulate by code the whole process, that is to say:

edit1 takes the focus, accepts the content and goes to edit2, accepts the content and goes to edit3 and finally presses the accept button.

ejemplo.png


I've tried it this way but it doesn't work:

B4X:
    ed1.RequestFocus
    ed1_EnterPressed
    ed2.RequestFocus
    ed2_EnterPressed
    ed3.RequestFocus
    ed3_EnterPressed
    bt1_Click

How should I do it by code?
Regards.
 
Solution
test:
much better using B4XFloatTextField
enter and tab key control.

Note:
allows you to move between fields, if they have a value (which can be zero).
and the button will only be activated when the expected results are correct

P.S:
The data entry has not been validated

vecino

Well-Known Member
Licensed User
Longtime User
Thank you very much, klaus, I see I didn't explain myself correctly, the translator and I don't get along well :)

I'll explain it better, when leaving ed1 some calculations are made and shown in ed2. When leaving ed2 other calculations are made and shown in ed3. Finally, when you exit ed3 and press the button, the results are saved.

The problem is that if the focus is on ed1 and the user presses the button then neither ed2 nor ed3 calculations are made.

That's why I ask if it is possible to simulate by code the whole process when the button is pressed, that is to say, when the user presses the button:
Accept ed1, enter ed2, accept ed2, enter ed3, and finally accept ed3.
That way all the calculations will be done.
Thank you very much.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Sorry, but I do not understand.
You need to explain more in detail what exactly you want to do.
Can you explain more in detail this:
Accept ed1, enter ed2, accept ed2, enter ed3, and finally accept ed3.
What do you mean with: Accept ed1, enter ed2 ?
What is the user supposed to do before pressing the button?
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Forgive my clumsiness, I am trying to explain it more clearly.
Just so you know what it is, it is an entry of goods into the warehouse when a lorry arrives.

In ed1 it's "pallets", ed2 it's "boxes" and ed3 it's "units".
Each item that arrives on pallets has a number of boxes and each box can have a number of units.
Example, we start, a pallet has arrived : item 0000001
ed1=0
ed2=0
ed3=0

The user is given a pallet and the user types it in ed1.
ed1 (pallets): 1
Each pallet contains 20 boxes
When passing the focus to ed2 it is multiplied 1x20 and displayed:
ed2 (boxes): 20
Now the focus goes to ed3 (units), if each box contains 10 units:
ed3 (units): 200

Finally press the button and 200 units are saved.

The problem is that when the focus is on ed1 and the user types "1 pallet", if the user presses the save button, the units will be 1x0x0=0 because the focus has not been passed and the value shown in ed2 and ed3 has not been accepted.

That is why I would like to know how I can "simulate" that the focus has moved to ed2, that the user has then moved to ed3 and finally clicked on the button.

I hope I have explained myself better with the example.
Thank you very much for your help.
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
Test:

This can guide you, I made it simple
1633382800499.png

Note:
allows you to move between fields, if they have a value (which can be zero).
and the button will only be activated when the expected results are correct

P.S:
The data entry has not been validated
 

Attachments

  • test.zip
    3.5 KB · Views: 165
Last edited:
Upvote 1

TILogistic

Expert
Licensed User
Longtime User
test:
much better using B4XFloatTextField
enter and tab key control.

Note:
allows you to move between fields, if they have a value (which can be zero).
and the button will only be activated when the expected results are correct

P.S:
The data entry has not been validated
 

Attachments

  • test.zip
    3.7 KB · Views: 187
Last edited:
Upvote 1
Solution

vecino

Well-Known Member
Licensed User
Longtime User
Thanks for the examples, the idea of disabling the button works perfectly for me.
Thank you very much, friends.
 
Upvote 0
Top