Virtual keyboard problem - Spanish characters

Monkey Targets Forums/Android/Virtual keyboard problem - Spanish characters

Amnesia(Posted 2012) [#1]
The current implementation in mojo of the virtual keyboard has a problem when dealing with spanish and other non-english characters. In order to write one of this characters (á, é, ö, ñ, for instance) you need to long press the corresponding key. This wasn't working and i started looking for the problem. Digging in mojo.android.java i found SetKeyboardEnabled method. This is ok, and i didn't found any issues related to my original problem. The problem is in the method BeginUpdate:
void BeginUpdate(){
	//
	//Ok, this isn't very polite - if keyboard enabled, we just thrash showSoftInput.
	//
	//But showSoftInput doesn't seem to be too reliable - esp. after onResume - and I haven't found a way to
	//determine if keyboard is showing, so what can yer do...
	//
	if( keyboardEnabled ){
		InputMethodManager mgr=(InputMethodManager)MonkeyGame.activity.getSystemService( Context.INPUT_METHOD_SERVICE );
		mgr.showSoftInput( MonkeyGame.view,0 );//InputMethodManager.SHOW_IMPLICIT );
	}
}

Basically what this does, is to show the keyboard on every update. This is the problem, calling this method on every frame, makes it impossible to long press any key. As a test i commented every line in this method and it worked. The problem, and the original reason that this hack existed, is that when you suspend the app while showing the virtual keyboard, when you resume the app the keyboard remains hidden. So i tried different solutions to address this problem. I tried calling EnableKeyboard in the OnResume method and then i tried calling it on the first frame after resuming, but none of these methods worked. For an extrange reason, showSoftInput didn't worked when resuming the app (i debugged it to verify that showSoftInput was called)
What i finnally did, and what i think is the simplest solution that will work on most of the cases, is just to leave it hidden. In my case, i have a form and the keyboard pops up when the user press an input box. If the app is suspended, i just cancel the current input state and when the app resume i just show the form, leaving it to the user to press the input box to show the keyboard. In the end, worst case scenario, he will lose what he wrote in one input box, not too bad, if the alternative is not being able to write año, or mötorhead :P
In any case, i think the BeginUpdate method should not call showSoftInput in every frame, so it'd be nice if this feature is added in the next update, maybe as an optional parameter to the EnableKeyboard method.
If anyone has found an alternative solution to this problem please share! :)

www.AmnesiaGames.cl


Midimaster(Posted 2012) [#2]
I have the same problem with german umlauts ÄÖÜ. But I do not understand how to use this solution. I'm not firm with Java.

I found the code above in my build folder in ....
"C:\Monkey\MyGame\MyGame.build\android\src\com\midimaster\vote"

..but now how to continue?

Could somebody please describe me, how to change Java source codes, so that I can use them as default for the future and not to loose with the next monkey update?

Perhaps the support of the whole keyboard (with special characters) is so important, that we should offer it as a regular monkey feature?

Is there any (beginner) tutorial about combining java (as extern) and monkey code?