Android Question Resumeable Sub Question [B4X] (SOLVED)

ilan

Expert
Licensed User
Longtime User
can we do something like this in b4x?

B4X:
Private Sub someevent
    Log("1")
    Wait For (btn_Click) Complete(done As Boolean)
    Log(done)
    Log("3")
End Sub

Private Sub btn_Click As ResumableSub
    Log("2")
    Return True
End Sub

LOGS should show:

1
2
true
3

thanx

EDIT: the logs does show what is written above but the btn_click is called from the someevent sub and not after the user actually clicks the button. i would like the someevent sub to continue ONLY if user has clicked the button. similar to Mesgbox2 approach.
 

Sagenut

Expert
Licensed User
Longtime User
B4X:
Private Sub someevent
    Log("1")
    Wait For ButtonClicked(done As Boolean)
    Log(done)
    Log("3")
End Sub

Private Sub btn_Click
    Log("2")
    CallSubDelayed2(Me, "ButtonClicked", True)
End Sub

Try this
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
I don't know what you are trying to achieve. btn_Click is not a Resumable Sub, declaring it's return as such does not make it so. You may just as well call it directly.

You can also declare a return type for btn_Click if necessary and return a value, the Click event called by the system ignores the return value, though whether Erel would think that this is a good idea I don't know!

If in fact you wanted to wait for the btn_Click event you can do so, but in that case Sub btn_Click will never run as Wait For will swallow the event
Wait For Button2_ClickWait For Button2_Click:
Wait For btn_Click
 
Upvote 0
Top