I have a (child)-activity, which user can close clicking a label (lblback) or with Back-key. If user has edited on of the textfields on this activity these changes must be saved.
I tried it this way:
But the code seems to return from sub AskForSave, Line "Wait For Msgbox_result.. " to the calling sub and activity is finished without saving.
What must I change for this issue to get it to work properly? Must I use the non-async msgbox here?
I tried it this way:
B4X:
Sub LblBack_Click
If hasChanges Then AskForSave
Activity.Finish
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event, also cancelt den Schließen-Vorgang
If KeyCode = KeyCodes.KEYCODE_BACK And hasChanges Then
AskForSave
End If
Return False
End Sub
private Sub AskForSave
Msgbox2Async("Es gibt ungesicherte Änderungen. Sollen die gespeichert werden?", "Bitte wählen!", "Ja", "", "Nein", Null, False)
Wait For Msgbox_Result (Result As Int) 'after this line, sub is left
If Result = DialogResponse.POSITIVE Then
BtnSave_Click
End If
hasChanges=False
End Sub
But the code seems to return from sub AskForSave, Line "Wait For Msgbox_result.. " to the calling sub and activity is finished without saving.
What must I change for this issue to get it to work properly? Must I use the non-async msgbox here?