I've been coding all day and my mind is probably a bit tangled up as I am suffering a blind spot. In the old days we would use a modal Msgbox2 to block a close request event until the user decides and closes the dialog..
B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'return true if you want to consume the event
If KeyCode = KeyCodes.KEYCODE_BACK Then
Dim res As String = Msgbox2("Do you really want to exit?", "", "Yes", "", "No", Null)
If Not(res = DialogResponse.POSITIVE) Then Return True
CheckSave
End If
Return False
End Sub
In the brave new world of Msgbox2Async how do we achieve the same thing? Can we achieve the same thing?
I have this code ,which I want to show the message when the user press the back button (keycode_back): Sub Activity_KeyPress (KeyCode As Int) As ResumableSub If KeyCode = KeyCodes.KEYCODE_BACK Then Msgbox2Async("Do you need to click in the button!","Interruped", "Continue", "Cancel"...
Sub Activity_KeyPress (KeyCode As Int) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then
Activity_Close(KeyCode)
End If
Return True
End Sub
Sub Activity_Close (KeyCode As Int) As ResumableSub
If KeyCode = KeyCodes.KEYCODE_BACK Then
Msgbox2Async("Do you really want to exit?", "", "Yes", "", "No", Null, False)
Wait For Msgbox_Result (Result As Int)
If Result = DialogResponse.POSITIVE Then
Activity.Finish
End If
End If
Return False
End Sub
@Mahares our postings crossed. Thanks, your link looks remarkedly like what I came up with. Strange that I didn't find it when searching the forum - wrong search terms I guess.