- Home /
TouchScreenKeyboard not working with GUI.TextArea (tested with Android tablet)
I am trying to make a Gui.TextArea to receive the input from my Android tablet. I need the user to be able to edit the text from the textarea.
void Start () { TouchScreenKeyboard.hideInput = true;
keyboard = new TouchScreenKeyboard("", TouchScreenKeyboardType.NumberPad, false, true, false, false, "");
keyboard.active = false;
}
void OnGUI(){
if (GUI.Button(new Rect(0, 280, 150, 40), "Show kyeboard")){
keyboard.active = true;
TouchScreenKeyboard.Open(keyboard.text, TouchScreenKeyboardType.NumberPad, true, false);
}
if (GUI.Button(new Rect(200, 280, 150, 40), "Hide kyeboard")){
keyboard.active = false;
}
// I create a box and the textarea
Rect texareaLocation = new Rect(10, 10, 200, 200);
Rect boxLocation = new Rect(texareaLocation.x - 2, texareaLocation.y - 2, texareaLocation.width + 4, texareaLocation.height + 4);
GUI.Box(boxLocation, "");
keyboard.text= GUI.TextArea(texareaLocation, keyboard.text, fontStyle);
}
This code is working on my PC (I can write, edit, select text into the textArea) When I deploy on my Android tablet the following are happening: I can write and delete text only from the end of the string (I cannot move the cursor - at the beginning or before a word I entered ... ) I cannot select the text from the textArea
For example if I am trying to move focus on other control after a certain text is entered I cannot do that on Android. like this:
if (keyboard.text != null && keyboard.text.Length >= 1)
{
GUI.FocusControl("textarea2"); // the focus is not changing
}
Also the Event.current.keyCode
is not detected when typing from Touch Screen Keyboard
Can you please help? What I am doing wrong? I don't understand how this touch TouchScreenKeyboard is working when: TouchScreenKeyboard.hideInput = true;
sounds similar to my problem. i'm on iOS, and my keyboard won't even show up.
Your answer
Follow this Question
Related Questions
How to save text and display using Touch Screen Keyboard 1 Answer
What is the command to check whether player is touching the screen or not?? 1 Answer
How can I tell if the device I am on supports touch? 4 Answers
Moving object to position of finger at screen 1 Answer
how to convert Input.mousePosition into iphone/android accelerometer? 1 Answer