Merge pull request #7491 from Dhilan007/v3-320final

fixed text line wrap issue in UITextField.
This commit is contained in:
minggo 2014-07-17 16:48:41 +08:00
commit c482e2e14f
3 changed files with 5 additions and 19 deletions

View File

@ -186,7 +186,7 @@ bool LabelTextFormatter::alignText(Label *theLabel)
int i = 0;
int lineNumber = 0;
int strLen = static_cast<int>(theLabel->_currentUTF16String.length());
int strLen = theLabel->_limitShowCount;
std::vector<char16_t> lastLine;
auto strWhole = theLabel->_currentUTF16String;

View File

@ -799,24 +799,9 @@ void TextField::adaptRenderers()
void TextField::textfieldRendererScaleChangedWithSize()
{
if (_ignoreSize)
{
_textFieldRenderer->setDimensions(0,0);
_textFieldRenderer->setScale(1.0f);
}
else
if (!_ignoreSize)
{
_textFieldRenderer->setDimensions(_contentSize.width, _contentSize.height);
Size textureSize = getContentSize();
if (textureSize.width <= 0.0f || textureSize.height <= 0.0f)
{
_textFieldRenderer->setScale(1.0f);
return;
}
float scaleX = _contentSize.width / textureSize.width;
float scaleY = _contentSize.height / textureSize.height;
_textFieldRenderer->setScaleX(scaleX);
_textFieldRenderer->setScaleY(scaleY);
}
_textFieldRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
}
@ -871,7 +856,7 @@ void TextField::copySpecialProperties(Widget *widget)
void TextField::setTextAreaSize(const Size &size)
{
_textFieldRenderer->setDimensions(size.width,size.height);
this->setContentSize(size);
}
void TextField::setTextHorizontalAlignment(TextHAlignment alignment)

View File

@ -275,7 +275,8 @@ bool UITextFieldTest_LineWrap::init()
// Create the textfield
TextField* textField = TextField::create("input words here","fonts/Marker Felt.ttf",30);
textField->ignoreContentAdaptWithSize(false);
textField->setContentSize(Size(240, 160));
((Label*)(textField->getVirtualRenderer()))->setLineBreakWithoutSpace(true);
textField->setContentSize(Size(240, 70));
textField->setTextHorizontalAlignment(TextHAlignment::CENTER);
textField->setTextVerticalAlignment(TextVAlignment::CENTER);
textField->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f));