Thanks Erel,
I got it to WAIT, but it doesn't return to the calling routine.
MAIN CODE
B4X:
...
Activity.LoadLayout("Main")
CustomMessageBox.SetTitleText("Please choose a day")
CustomMessageBox.SetTitleTextColor(Colors.Yellow)
CustomMessageBox.SetTitleTextSize(30)
CustomMessageBox.SetBackgroundColor(Colors.Gray)
CustomMessageBox.SetBitmap( LoadBitmapSample(File.DirAssets, "warning.png", 50dip, 50dip))
Dim Result As Res
CustomMessageBox.Show(Answers)
Wait For CustomMessageBox.btnAnswer_Click Complete (Result As res)
Log(Result) <-----<<< THIS LINE and below ARE NEVER EXECUTED
Select Case Result.Index
Case 0
Log("SELECTED " & Result.index)
Case 1
Log("SELECTED " & Result.index)
End Select
...
End Sub
CUSTOMMESSAGEBOX CODE
B4X:
Sub Class_Globals
...
Type Res(Index As Int, Value As String)
...
End Sub
public Sub Show(AnswerArray() As String)
shows buttons for clicking all with btnAnswer_Click as the click event
...
End sub
Public Sub btnAnswer_Click As ResumableSub
Dim btn As Button
btn = Sender
Dim Result As Res
Result.Initialize
Result.Index = btn.Tag
Result.Value = btn.Text
SetVisible(False)
Log("btnanswer click " & Result)
Return Result
End Sub
Thanks Erel,
So I need to delete the btnanswer_Click routine...? How will Result be created?
Also, I'm not clear on the Wait For statement in MAIN.
Wait For CustomMessageBox.show Complete (Result As Res)
The SHOW routine never runs and thus, no buttons are showing...
Obviously, I don't understand your guidance. Can you help ?
Thanks,
Rusty
Wait For (CustomMessageBox.Show(Array As String("Card", "Cancel", "Set"))) Complete (Result as Res)
Note: Since Res is a Type, make sure Main knows about the Type.
Your CustomMessageBox show method becomes (this is just an expansion of @Erel's post #5)
B4X:
public Sub Show(AnswerArray() As String) As ResumableSub
'Here goes your original Show method code
shows buttons for clicking all with btnAnswer_Click as the click event
...
'If you had a return in your original Show method, remove it
'Finish up the Show method with the Wait For and the same processing statements that you originally
' used in Sub bntAnswer_Click
Wait For btnAnswer_Click
Dim btn As Button
btn = Sender
Dim Result As Res
Result.Initialize
Result.Index = btn.Tag
Result.Value = btn.Text
SetVisible(False)
Log("btnanswer click " & Result)
Return Result
End Sub