I am working on a game which will run on IOS and Android devices. For IOS its complete, but on Android only the work that is pending is to get text input working properly.
There are some conditions for text input like:
1) User can only input characters(a-z,A-Z).
2) The length of the characters should not exceed 7.
The code for satisfying this two conditions is below:
bool CEnterNameLayer :: onTextFieldInsertText(CCTextFieldTTF * pSender, const char * text, int nLen)
// if insert enter, treat as default to detach with ime
if ('\n' == *text)
a = 97 z = 122
A = 65 Z = 90
int c = *(text);
if(c < 65 || (c > 90 && c < 97) || c > 122)
// if the textfield's char count more than CHAR_LIMIT, doesn't insert text anymore.
if (pSender->getCharCount() >= CHAR_LIMIT) // CHAR_LIMIT = 7
The above code works perfectly on IOS devices but not on Android.
On Android it accepts all characters and also i am not able to control the number of characters. I have checked TextInputTest but that is also not working on Android.
I am using cocos2d-1.0.1-x-0.13.0.
I am testing it on Android OS 2.2.
I am not able to understand what is going wrong. Please help me out or point me into the right direction.