Hello everyone,
Firstly, the following code
works perfectly.
If the user does not enter a File Name, the message box appears, warning the user of his / her mistake, waits for the reply, then either dismisses the Message Box and waits for a file name of returns the current file name and continues on.
The problem is, I want to do the right thing and replace the Magbox2 with MsgBox2Async.
Now, I have successfully used MsgBox2Async elsewhere in the program but, none of the Subs where MsgBox2Async reside need to return a value.
SKB_HandleAction on the other hand Does need to return a value to it's calling sub, to inform as to weather or not to hide the Keyboard.
As Erel informs in his Video on Resumable Subs, executing Sleep or Wait For is akin to Returning so, SKB_HandleAction immediately wants to return to it's calling sub, whereas a Modal Message Box will wait until it is dismissed.
So, how do I use MsgBox2Async correctly inside SKB_HandleAction.
SKB_HandleAction needs to wait for the Message Box to be dismissed until returning to its calling sub.
MC73 did post an example of calling a different sub where MsgBox2Async resided but, again, the calling sub did not need to return a value.
Thank You
Gavin
Firstly, the following code
B4X:
Sub SKB_HandleAction As Boolean
'We use the HandleAction event,
'so as to prevent the Keyboard
'closing, if the user forgets
'to enter a File Name.
Dim e As EditText
e.Initialize("")
e = Sender
etFile.Text = etFile.Text.Trim
If etFile.Text = "" Then
Dim Result As Int = Msgbox2("Please Enter a File Name.", "No File Name Entered.", "", "Cancel", "Ok", Null)
If Result = DialogResponse.NEGATIVE Then
Return True
Else If Result = DialogResponse.CANCEL Then
etFile.Text = lblTitle.Text
CallSub(Me, "lblSave_Click")
Return False
End If
End If
End Sub
works perfectly.
If the user does not enter a File Name, the message box appears, warning the user of his / her mistake, waits for the reply, then either dismisses the Message Box and waits for a file name of returns the current file name and continues on.
The problem is, I want to do the right thing and replace the Magbox2 with MsgBox2Async.
Now, I have successfully used MsgBox2Async elsewhere in the program but, none of the Subs where MsgBox2Async reside need to return a value.
SKB_HandleAction on the other hand Does need to return a value to it's calling sub, to inform as to weather or not to hide the Keyboard.
As Erel informs in his Video on Resumable Subs, executing Sleep or Wait For is akin to Returning so, SKB_HandleAction immediately wants to return to it's calling sub, whereas a Modal Message Box will wait until it is dismissed.
So, how do I use MsgBox2Async correctly inside SKB_HandleAction.
SKB_HandleAction needs to wait for the Message Box to be dismissed until returning to its calling sub.
MC73 did post an example of calling a different sub where MsgBox2Async resided but, again, the calling sub did not need to return a value.
Thank You
Gavin