I'm using editBox focus change event to understand that the user finished entering the text , I have a list of edit boxes, and when the user moving from one to the other (in no predefined order, its what the user wants) I act on the value (save it to a file)
using the enter pressed event is not natural in my mind, people will move to the editBox they want and not going to press enter on the keyboard.
the only problem I have is that when user put data in the last field he might just press the back button exit the application in this case my app will go to pause activity and focus change event will never be thrown
is that a bug or an android behavior ?
Did you already consider this: Intercept the back key press to prevent premature exit of the application. See below:
B4X:
Sub Activity_KeyPress(KeyCode As Int) As Boolean
Dim Selection As Short
If KeyCode = KeyCodes.KEYCODE_BACK Then
Selection = Msgbox2("Did you remember to save record. Exit application?".ToUpperCase, "C o n f i r m a t i o n", "Yes", "", "No", Null)
Select Selection
Case DialogResponse.POSITIVE
Activity.Finish
Case DialogResponse.CANCEL, DialogResponse.NEGATIVE
Return True
End Select
End If
End Sub
Yea I thought about that what I need to do ig that happen is going over all editboxes or find the last one with focus get the text and save it.
I can do that the way you suggested or directly from pause activity sub.
I was looking for more elegant way that is part of the editbox event flow .
The lostFocus is triggered when something else receives focus, in Android and Windows. That's its meaning. When you hit a 'back' or 'exit' or 'minimize' (windows) there is no loss of focus.
Why not adding a 'save' button? After all, it's the user who should decide whether to save the bunch of data or abort them, under normal conditions.