B4X:
Sub MainForm_CloseRequest (EventData As Event)
EventData.Consume
Dim sf As Object = xui.Msgbox2Async("Save changes?", "Title", "Yes", "Cancel", "No", Null)
Wait For (sf) Msgbox_Result (Result As Int)
If Result = xui.DialogResponse_Positive Then
'save changes
End If
If Result <> xui.DialogResponse_Cancel Then
MainForm.Close
End If
End Sub
This means that we must consume the event before calling Wait For. Otherwise the form will be closed.
If the user didn't click on cancel then we call Form.Close to close it. The CloseRequest event will not be fired in that case.
Last edited: