How do I know if the keyboard is showing?
Monkey Targets Forums/Android/How do I know if the keyboard is showing?
| ||
If I EnableKeybaord is there a way to know if it is already showing? I guess I could have separate areas of the screen to tap on to turn it on/off - but as posted elsewhere on the forums that I found it can create issues if you keep enabling it when it's already showing. I've looked at both the EnableKeyboard and DisableKeyboard commands and they both return an Int - but after mucking around with if EnableKeyboard()=True/0/1 etc. it doesn't seem to be returning a value that is usable. I notice that some apps also give you a different default keyboard - either the standard qwerty or the standard numeric keyboard depending on what type of input you are looking for. Some keyboards also replace the enter key with a GO button - meaning you type your value and then press Go to proceed which is more logical than pressing an enter key which is normally used to move down one line in a text box. Other apps also have a Next / Prev button to move between multiple fields when entering information. Is any of this supported in Monkey? A monkey keyboard module that looks very similar to the targets existing keyboard would be really good if Monkey doesn't support these things. |
| ||
Got around if this way, possibly not the best approach but anyway...Method OnUpdate:Int() If MouseHit() If keyboardShowing Then DisableKeyboard() keyboardShowing = False Else EnableKeyboard() keyboardShowing = True EndIf EndIf Return 0 End Just made a Global variable keyboardShowing for the moment to handle this. Doesn't answer my other questions though. Any input appreciated. |
| ||
As far as I know currently you have to remember it like you did, which isn't a problem because you know when you activate it. ;) |
| ||
Thanks @Xaron. Trying out a few things, and it does seem very laggy in either showing the keyboard or removing the keyboard. E.g. It takes around 2-3 seconds for the keyboard to be shown/hidden - not a big problem. But pressing the keys seems to be even worst, to the point where trying the use the keyboard is just unusable. This is pretty much my entire program: Method OnUpdate:Int() If MouseHit() And MouseY() < 300 Then If keyboardShowing Then DisableKeyboard() keyboardShowing = False Else EnableKeyboard() keyboardShowing = True EndIf EndIf Return 0 End Any one else have issues with the keyboard on Android? I'm tried running in both debug & release mode with no change. Running on a Galaxy Tax 3. |
| ||
It runs fine on my Galaxy S5. Try this com from the bananas/mak it works fine on my Android device Import mojo Class MyApp Extends App Field str$="Started!",old$ Field enabled? Method OnCreate() SetUpdateRate 15 End Method OnUpdate() If KeyHit( KEY_MENU ) Print "Menu key hit!" Else If KeyHit( KEY_SEARCH ) Print "Search key hit!" Endif If enabled Repeat Local char=GetChar() If Not char Exit Print "char="+char If char>=32 str+=String.FromChar( char ) Else Select char Case 8 str=str[..-1] Case 13 If str.Trim()="bye" Error "" 'test abrupt exit with keyboard open enabled=False DisableKeyboard Case 27 str=old enabled=False DisableKeyboard End Endif Forever Else If KeyHit( KEY_LMB ) old=str str="" enabled=True EnableKeyboard Endif Endif End Method OnRender() Cls Scale 2,2 DrawText "Text: "+str,0,0 If Not enabled DrawText "Click anywhere to type text...",0,20 End End Function Main() New MyApp End |
| ||
Any one else have issues with the keyboard on Android? Every Android developer that has ever tried to use on screen keyboard API in a game. IMHO the Android keyboard API is unfit / not designed for use with with fullscreen GL game displays. It's behaviour and the amount of visible screen it uses is (un)defined, affected by a combination of : * Manufacturer * Android Version * User Settings * Language * Orientation * Paired Devices * Installed third party onscreen keyboards I would consider learning a bit of Java to add an activity dedicated to entering of text hooked up to Monkey in the form of a RequestTextInput command or implement you own on screen keyboard in the style of your Game UI. |