How can I select all after activating the InputField in Android?

InputField selects and highlights all of the text on Windows Editor when I activate it. This is the desired behaviour. I want users to tap on the input field and I want the input field to select all things so that if the users start typing they type after erasing everything there was in the first place.

In Android however this behaviour is out of the window. The input field activates. The mobile device keyboard pops up but all of the text is unhighlighted and not selected. The carat has moved to the end.


I tried the following:
-Using a co-routine and calling activation and selection methods one at a time.
-Creating a child extension from InputField and calling the protected method SelectAll()


These didn’t work. I’m about to lose my hair. Any help is appreciated.

The work around I found is as follows: I extended the InputField class and added a parameter called previousEntry. When the user taps on the InputField I store the entry in previousEntry and clear the InputField.Text completely and the user now can type a new entry as they please. If they back out of it without typing anything the previousEntry is remembered. If they type something new the previousEntry is discarded and the new entry is used.

Unity please add options to clear/select all/put carat at end/put carat at start etc. options for this. NGUI used to have these and they were super helpful.

Another work around, on android, without extending the InputField class is to use the placeholder of the input field. (If you do not need the placeholder to begin with.)


Add a function that runs on “OnEndEdit”, and do the following:
string value = InputField.text; InputField.text = ""; ((Text)InputField.placeholder).text = value;


When the user focuses on the InputField, the placeholder disappears and allows the user to start typing from the beginning.
On end edit, the value of the InputField is reset and the placeholder gives the illusion to the user that the value is entered.

Not very elegant but does the job.