Text Field (in Beta)

In the beta for 1.1, I’ve been playing with text fields and keyboards. Through the documentation, I have found out how to display various different keyboards by declaring an iPhoneKeyboardType when opening the keyboard via iPhoneKeyboard.Open(). However, text fields seem to open up the keyboard automatically, leaving no place for me to declare iPhoneKeyboardType. Any of you beta users know how would I set up a text field to open up a non-default keyboard such as the NumberPad?

Shouldn’t you be posting this on the beta list?

The beta list refuses to let me send emails. I’ve tried several times. Oleg has forwarded the issue to sysops but this issue is mildly time-sensitive as it is the last problem to resolve before I have a product ready to ship. I figured no harm in asking the community.

My apologies if asking that here is bad form. I’m not familiar with Unity’s protocol on discussion of beta features in a public location.

Usually I’d shut it down, but 1.1 and its features are pretty well known, plus if you’re genuinely having trouble posting to the beta list then that sucks (our sysop is on vacation).

Wish I had an answer to your question :roll:

Edit- I’ll post this to the beta list for you and ask someone to answer here.

This works for me pretty good:

keyboard = iPhoneKeyboard.Open(highscoreName, iPhoneKeyboardType.ASCIICapable);

or

keyboard = iPhoneKeyboard.Open(highscoreName, iPhoneKeyboardType.NamePhonePad);

Hey man - I am assuming that you are going to have to do this old school ie. Read the data from the keyboard and then clean it after. You can send the user an error that they can only enter certain data. Not very efficient but it will work if you are crunched for time : )

Haha - Martin beat me to it with a better answer!

That much I got on my own. I know how to open the keyboard via iPhoneKeyboard.Open() and set the string to the keyboard’s input. The problem is related directly to GUI Text fields. I have a text field declared in my scene. Example:

var stringToEdit = "Hello World";

function OnGUI () {
// Make a text field that modifies stringToEdit.
stringToEdit = GUI.TextField (Rect (10, 10, 200, 20), stringToEdit, 25);
}

When I tap the generated text field on iphone, the keyboard appears. Notice I am not manually calling iPhoneKeyboard.Open() to initialize the keyboard for the text field, so I can’t use that function call to dictate which keyboard type to open.

Hmm, I honestly do not understand exactly the problem you have. Can you try to describe it in a different way? What is the problem with the text field? I’m not using any GUI text fields anymore, but have a button to change the current name the user uses. If I tap that button the keyboard appears and after pressing “done” on the iPhone keyboard it disappears and the new name is taken over. What is your approach?

The difference lies in buttons vs text fields. If you declare a generic button in GUI, a keyboard does not pop up. You have to manually call iPhoneKeyboard.Open() in order to make the keyboard appear. Text fields, however, make a keyboard appear by default. No call to iPhoneKeyboard.Open() is ever made to show the keyboard when you tap a text field.

Ah, now I understand. But at the same time, sorry, I have no clue how to solve that. :slight_smile:

Thanks for giving it a go anyway. At this point I’ just considering turning the text field into a similarly-skinned box and calling the keyboard manually so I can set the keyboard type.

Fill the feature request, please.

What became of this?

Seems odd that you can raise a keyboard via TextField, but never be able to specify the keyboard type (via iPhoneKeyboardType).

bump

What I did now is to use a button, skin it like a textfield, if you click it opens the keyboard, new problem arises: text on a button doesn’t behave like text in a textfield, so I magically switch the text-alignment of the GUIStyle from left-aligned to right-aligned when you type more than 10 characters - works surprisingly well for such a dirty hack…

But I still can’t use my component, because I can’t get the keyboard to rotate without changing screen.orientation, even though the docs say the keyboard reacts to device orientation… sigh