Restrict iOS keyboard input to integer?
Hi all,
I'm trying to work out how I can restrict the new feature "Keyboard Input" on my iphone game to only accept a whole number? Even if I set the 'Change Attribute' field to something like an integer, it seems to happily accept anything typed in there.
Ideally, if I could restrict it at the time of entering that would be best, but even if it let the user input whatever they wanted, ran a quick test to see if it was an integer and then gave them an error or prompt would also be fine. Is there any way to test what is saved in attributes?
Regards,
Sam
I'm trying to work out how I can restrict the new feature "Keyboard Input" on my iphone game to only accept a whole number? Even if I set the 'Change Attribute' field to something like an integer, it seems to happily accept anything typed in there.
Ideally, if I could restrict it at the time of entering that would be best, but even if it let the user input whatever they wanted, ran a quick test to see if it was an integer and then gave them an error or prompt would also be fine. Is there any way to test what is saved in attributes?
Regards,
Sam
Comments
You need 2 attributes to make it work with the method I worked out.
First one is a text, second one is an int, pop up the keyboard with it set to change the string. Then check if the string changes and try and change attrib the int To the string attrib. If it's a valid whole number it will be set correctly, if not you get 0.