CCTextFieldTTF with support for password inserting

Hello,
I didnt find possibility how to set CCTextFieldTTF to password mode (while after char inserting is changed to star).

Did you plane this features for CCTextFieldTTF?

We will add it if it is possible. But you may wait some days for this feature.
#730 is created for it.

+1

I could provider method (that i use now)

example:
in ios (CCLayer)

AppController.h
UITextField* qoo ( it’s global member here )

AppController.cpp

didFinishLaunchingWithOptions
{
// set UITextField attribute which u want
// like this
[ qoo setSecureTextEntry:YES];
}

-(void)textFieldDidEndEditing:(UITextField**) textField
{
// here u can get your input
const char** input = [qoo.text ( remember convert to UTF8 String )]
// call abc (global function in cpp )
SetText( input ) // now u can get input
}

in cpp ( your implement…)

abc.h
// it’s a global function too
void SetText(const char* text);

this is not a oop program :stuck_out_tongue:
hope it could help some one :wink:

Hello,
if you dont need star by writing, but only on screen you can easy modify function void CCTextFieldTTF::setString(const char *text).

// input text property
void CCTextFieldTTF::setString(const char *text)
{
    CC_SAFE_DELETE(m_pInputText);

    if (text)
    {
        m_pInputText = new std::string(text);
    }
    else
    {
        m_pInputText = new std::string;
    }

    // if there is no input text, display placeholder instead
    if (! m_pInputText->length())
    {
        CCLabelTTF::setString(m_pPlaceHolder->c_str());
    }
    else
    {
        //begin code modification
        if (mIsPassword)
        {
            int length = _calcCharCount(m_pInputText->c_str());
            std::string passwordText;

            fillWithStars(passwordText, length);
            CCLabelTTF::setString(passwordText.c_str());
        }
        else
        {
            CCLabelTTF::setString(m_pInputText->c_str());
        }
        //end code modification
    }
    m_nCharCount = _calcCharCount(m_pInputText->c_str());
}

And one more feature request:

It will be great if we can set character limits for TextField.

thank u.it’s useful for me