Android Question [Solved]Do we have any control over the OSK in B4A?

DataMiser

Member
Licensed User
Been looking for info on OSK and B4A, haven't found much so far so thought I would post the question here.

Are there any methods in B4A that allow for any control over the OSK beyond which OSK pops up.
Ideally I would like to be able to pop up the OSK when an edit field gets focus via code without requiring the user to tap on it first and of course would also like to be able to make the OSK go away under some conditions.

I do not know if either of these are possible, any related info could be helpful.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
OSK = IME = soft keyboard

1. See this tutorial: Handle the soft keyboard with the IME library
2. If you want the keyboard to show when the activity becomes visible then add this line to the manifest editor:
B4X:
SetActivityAttribute(YourActivity, android:windowSoftInputMode, adjustResize|stateVisible)
 
Upvote 0

DataMiser

Member
Licensed User
Thanks, Looks like that should help a lot.

One more question.
I threw a few lines into one of my projects to get the keyboard to popup and find that under normal conditions it is not showing up. If however I set a break point on that line then when I resume the keyboard does appear.
B4X:
Sub Activity_Create(FirstTime As Boolean)
 IME1.Initialize("IME1")
 Activity.LoadLayout("scrSignIN")
 modCommon.ResetUserFontScale(Activity)
 txtEmployee.RequestFocus
 IME1.ShowKeyboard(txtEmployee)
End Sub

If I set a breakpoint on the IME1.ShowKeyboard ... line then I get the keyboard when I resume execution
If I set the break point before that line I do not get the keyboard
If I omit the line above to request focus I do not get the keyboard even with the breakpoint on the IME line.

What am I missing?
 
Upvote 0

DataMiser

Member
Licensed User
Ahh, I had copied that line from a post and the part for the activity name just said main and I had not changed it to match the activity I was using.
When I went back and looked again at your post then my mistake was obvious.

Thanks,
 
Upvote 0
Top