This commit is contained in:
andyque 2015-01-26 18:26:59 +08:00
parent d94c26006b
commit 95e8072afa
2 changed files with 16 additions and 7 deletions

View File

@ -599,26 +599,30 @@ void TextField::update(float dt)
detachWithIMEEvent();
setDetachWithIME(false);
}
if (getAttachWithIME())
{
attachWithIMEEvent();
setAttachWithIME(false);
}
if (getInsertText())
{
//we update the content size first such that when user call getContentSize() in event callback won't be wrong
_textFieldRendererAdaptDirty = true;
updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize());
insertTextEvent();
setInsertText(false);
_textFieldRendererAdaptDirty = true;
updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize());
}
if (getDeleteBackward())
{
deleteBackwardEvent();
setDeleteBackward(false);
_textFieldRendererAdaptDirty = true;
updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize());
deleteBackwardEvent();
setDeleteBackward(false);
}
}

View File

@ -426,7 +426,7 @@ bool UITextFieldTest_PlaceHolderColor::init()
Size widgetSize = _widget->getContentSize();
// Add a label in which the textfield events will be displayed
_displayValueLabel = Text::create("Set place hold color","fonts/Marker Felt.ttf",32);
_displayValueLabel = Text::create("You should see 16.50000, 34.0000 in the output window the first time you type","fonts/Marker Felt.ttf",12);
_displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
_displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f));
_uiLayer->addChild(_displayValueLabel);
@ -473,7 +473,12 @@ void UITextFieldTest_PlaceHolderColor::textFieldEvent(Ref *pSender, TextField::E
break;
case TextField::EventType::INSERT_TEXT:
{
_displayValueLabel->setString(String::createWithFormat("insert words")->getCString());
TextField* textField = dynamic_cast<TextField*>(pSender);
auto& contentSize = textField->getContentSize();
CCLOG("%f, %f", contentSize.width, contentSize.height);
}
break;
case TextField::EventType::DELETE_BACKWARD: