how to create text input widget

how to create text input widget
0.0 0


hi all,
as a newbee to cocos2d-x,how to create a text input widget to input name ,password etc. I review the class CCTextFieldTTF, but failed to find some useful method
such as setborder, setbackground color and settextcolor, such like this,

textFieldCtl=[[UITextField alloc] initWithFrame:CGRectMake(100.0f, 100.0f, 100.0f, 25.0f)];
[textFieldCtl addTarget:self action:@selector(textFieldAction: ) forControlEvents:UIControlEventEditingDidEndOnExit];
textFieldCtl.backgroundColor = [UIColor whiteColor];
textFieldCtl.textColor=[UIColor blueColor];

seeking for your help.



You basically make one with a size, like so:

CCTextFieldTTF * userNameField = CCTextFieldTTF::textFieldWithPlaceHolder( "Username", CCSizeMake( 300, 24 ), kCCTextAlignmentLeft, "Arial", 12.0f );

What kid of method do you need? I’m not pretty good with ObjC but I assume you want one with background color?


yes, set background color and rounded border. See the attachment.