Issue using ui::TextField : the text doesn't move to the left when its longer than the width of the textfield

Hello, I would like to have the text inside my cocos2d::ui::TextField move to the left when we continue to type.
I have tried to use :
((Label*)(myTextField->getVirtualRenderer()))->setLineBreakWithoutSpace( false );
but the letters are rendered outside the size of my textField, the text is moving to the left only when the end of the screen is reached.

I’m opened to any ideas =)

Thanks

Do you also set the width or dimensions of the label?

Nothing is working. So far I’ve tried :

cocos2d::ui::TextField* pTest = cocos2d::ui::TextField::create("placeholder", "youblockhead.ttf", 20);
pTest->ignoreContentAdaptWithSize( false );
pTest->setTextHorizontalAlignment( TextHAlignment::CENTER );
pTest->setTextVerticalAlignment( TextVAlignment::CENTER );
pTest->setPosition( Vec2( 200, 100 ) );
pTest->setContentSize( size );


((Label*)(pTest))->setContentSize( size );
pTest->setContentSize( size );
pTest->setTextAreaSize( size );
((Label*)(pTest))->setDimensions( 150.0f, 40.0f );
((Label*)(pTest->getVirtualRenderer()))->setContentSize( size );
((Label*)(pTest->getVirtualRenderer()))->setDimensions( 150.0f, 40.0f );
((Label*)(pTest->getVirtualRenderer()))->setLineBreakWithoutSpace( false );

Might be a bug? I’m guessing the TextField class has been tested only for single line entry since that’s probably the common use case. I would have guessed that if you set the dimensions and line-break correctly you’d find that the text wraps.

I would create a test label (outside the textfield) by itself and set its contents to the same thing you tried to type in. Position and size it the same. This should wrap if you have it setup to wrap and the contents has the required ‘space’ to wrap against.

Can you share the contents of the text field where it should have wrapped, but didn’t? Then I can test and search for where there may be a bug.

I’ve tried with a test label, the text isn’t wrap if its too long. I have no content for the textfield because it will be the input of a user.

For example I have created a textfield which content will be an email. So if the user’s email is longer than the width of this textfield (that I have fixed), I would like to have the text moving to the left to see the end of the text.

they are for single line only.

check in this.

You may find that EditBox works for you instead since it uses the platform’s edit single line text field, though with a platform look instead of using the look and feel of your Game.

Looks like they are looking to improve Labels and text fields.
http://discuss.cocos2d-x.org/t/what-do-you-hate-most-in-terms-of-editbox-and-textfield/22436/5
Voice your issue and feature requests :smiley:

Thank you for your answers, I will try EditBox but it isn’t support yet in CocosStudio :frowning: