- Home /
How to set Android keyboard to capitalize each word
I have a feeling I know the answer to this (can't be done), but I searched around and could not find a direct Unity-built-in way to do this, so I'll ask in case anyone else has done this.
I just want to make the keyboard capitalize the first letter of each word on Android when I click on an Edit box (using 2D Toolkit). The keyboard pops up, but it's always lowercase.
The following link shows how to do it in Android, but I didn't find any direct interfaces in Unity to do this. http://developer.android.com/reference/android/widget/TextView.html#attr_android:capitalize
The problem is that Unity is creating a dynamic TextView that shows up above the keyboard and using that for text entry, and I don't know how to get access to that view control from within Unity, either through the JNI or exporting to eclipse, to change its behavior. Some digging into the Unity jar files reveals the code has been obfuscated though I could track toward the edit box fairly closely but just too difficult to read, and my client really doesn't want to spend a lot of time on this. If you know of a way, I would appreciate the solution.
Thanks, Chris
The only way I can think of doing this is without using a textfield or area.
If you show your text as a label or text mesh and encapsulate it with a rect you can check to see if a user touched the text if the touch position is within the rect, then you'd open open the TouchScreen$$anonymous$$eyboard. Of course you wouldn't be able to move the caret within a label but the input is shown above the soft keyboard any way (unless you hide it with TouchScreen$$anonymous$$eyboard.hideInput). But you'd be able to access the keyboards text.
In theory something like this:
if(textRect.Contains (touchPosition){
keyboard = TouchScreen$$anonymous$$eyboard.Open(text, TouchScreen$$anonymous$$eyboardType.Default);
}
if(keyboard != null){
text = keyboard.text;
}
GUI.Label(textRect, text);
Then you can parse the text however you like.
Your answer
Follow this Question
Related Questions
KeyNotFoundException: The given key was not present in the dictionary. 1 Answer
unity 5.3 android broadcast receiver not working 0 Answers
Android soft keyboard does not popup 1 Answer
Figure Where Keyboard ends. 1 Answer
TextFields Android issue: switching between different fields it copies the string 0 Answers