Android Question How to avoid DoEvents in this case?

LucaMs

Expert
Licensed User
Longtime User
I have an invisible EditText; when I set it to visible I want to show an IME keyboard (which puts the focus on it).

I used code similar to this:
B4X:
EditText1.Visible = True
CallSubDelayed2(Me, "ShowKeybord", EditText1)


Sub ShowKeybord(et As EditText)
    IMEKeyboard.ShowKeyboard(et)
End Sub

It works in debug mode; in release mode the EditText gets the focus but the sw keyboard is not shown.
Writing a DoEvents before IMEKeyboard.ShowKeyboard(et), all work as expected.


How to avoid DoEvents in this case?
 

LucaMs

Expert
Licensed User
Longtime User
Did you tried Sleep(0) instead of DoEvents?
Ops... no, I didn't. Since Sleep returns control to calling routines, I "fear" flow problems, so I try to avoid also Sleep. In this case, however, the calling routine is a view event routine, so it works without risk.

Thank you.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
DoEvents as far as I know allows next events to be processed. Flow is lost in any case. I never use this feature in any OS when on multi thread.
VB.Net DoEvents does not return control to the calling routine, it allows the system to process events. B4a DoEvents is different.
 
Upvote 0
Top