iPhoneKeyboard Set Text after validation

Hello. I have a question. I’m using the iPhoneKeyboard interface to get a users sign-in name. One issue we have is that not all characters are allowed in the username, so I want to limit the input to a subset of possible characters.

In the editor, I can do this just by caching the text and drawing the textbox, testing the return value it gives me. If the two are different, then I check for illegal characters. If there are illegal characters, then I revert back to the prior version of the username and notify the user that the character is invalid.

However, in the iPad, I instead call iPhoneKeyboard.Open() and pass in the initial text, I then simply poll for the value of the keyboard and return it to my function that will do the same check as above. However, if the new username is NOT valid, then I want to modify the text in the iPhoneKeyboard buffer so it has the invalid characters removed.

I see that the iPhoneKeyboard has a .text property (that we read), and I know that i can set the text in the Open() method, but my attempts to call a kb.text = newtext do not work (and do not cause an error).

I can see perhaps security implications for not allowing text to be modified, but am curious if anyone knows if the .text property really is readonly, or have any other insight as to why I’m not able to set it directly.

Thanks for any insight.

Follow up on this, the answer is that the .text property is settable as well as gettable. The error that prompted this confusion on my part was upstream of the code I was looking at.

So I was able to validate keyboard input on iPhone and reject text that wasn’t valid without the user having that text buffered on the iPad keyboard but missing from the actual text field being displayed.