ilan Expert Licensed User Longtime User Feb 21, 2022 #1 can we do something like this in b4x? B4X: Copy 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 Click to expand... 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.
can we do something like this in b4x? B4X: Copy 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 Click to expand... 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.
S Spavlyuk Active Member Licensed User Longtime User Feb 21, 2022 #2 Try: B4X: Copy Wait For btn_Click (done As Boolean) Upvote 0
Sagenut Expert Licensed User Longtime User Feb 21, 2022 #3 B4X: Copy 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
B4X: Copy 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
agraham Expert Licensed User Longtime User Feb 21, 2022 #4 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 Code: Copy Wait For btn_Click Upvote 0
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 Code: Copy Wait For btn_Click
ilan Expert Licensed User Longtime User Feb 21, 2022 #5 thank you very much @Sagenut and @agraham. both solutions works for me. it was simpler than i thought. thanks, guys ? Upvote 0
thank you very much @Sagenut and @agraham. both solutions works for me. it was simpler than i thought. thanks, guys ?