this doesn't work. to demonstrate, I opened a brand new b4xpages project from b4a 11.0 and changed the button click event from
B4X:
Private Sub Button1_Click
xui.MsgboxAsync("Hello world!", "B4X")
End Sub
to
B4X:
Private Sub Button1_Click
wait for (xui.MsgboxAsync("Hello world!", "B4X")) complete (o As Object)
B4XPages.ClosePage(Me)
End Sub
and when you touch the button, the dialog disappears and goes back to the mainpage with the button. nothing closes.
I've been trying to find a way to close a b4xpages app so it can be restarted by the user to reload all the data from scratch. A more elegant solution would be to restart a page, but as far as I can tell, only an activity can be restarted, and I can't see how to do that from within a b4xpage. thanks in advance!
Private Sub Button1_Click
xui.Msgbox2Async("Close?", "", "Yes", "", "No", Null)
Wait For Msgbox_Result (Result As Int)
If Result = xui.DialogResponse_Positive Then
B4XPages.ClosePage(Me)
End If
End Sub
that works, thank you! I am at awe over the power b4x has, but I can find very little information on how to use the Wait For command. I searched for almost an hour before I ran across Erel's b4j thread explaining resumable subs, and all I could get from it is an event name was to follow the Wait For statement. @angel_ , How did you know to use MsgBox_Result after your Wait For? what am I missing???
I just figured out that you can write it like this as well...
B4X:
Private Sub Button1_Click
Wait For (xui.Msgbox2Async("Close?", "", "Yes", "", "No", Null)) Msgbox_Result(Result As Int)
If Result = xui.DialogResponse_Positive Then
B4XPages.ClosePage(Me)
End If
End Sub
encapsulating the asynchronous call in parenthesis followed by the event name with its return parameters. The return parameters are optional, by the way, if you don't need to know which button was pressed.