mirror of https://github.com/axmolengine/axmol.git
issue #5110, refactor UIText
This commit is contained in:
parent
578ff2735d
commit
e6889dca36
|
@ -632,7 +632,7 @@ void WidgetPropertiesReader0250::setPropsForLabelFromJsonDictionary(Widget*widge
|
|||
bool touchScaleChangeAble = DICTOOL->getBooleanValue_json(options, "touchScaleEnable");
|
||||
label->setTouchScaleChangeEnabled(touchScaleChangeAble);
|
||||
const char* text = DICTOOL->getStringValue_json(options, "text");
|
||||
label->setText(text);
|
||||
label->setString(text);
|
||||
bool fs = DICTOOL->checkObjectExist_json(options, "fontSize");
|
||||
if (fs)
|
||||
{
|
||||
|
@ -1571,7 +1571,7 @@ void WidgetPropertiesReader0300::setPropsForLabelFromJsonDictionary(Widget*widge
|
|||
bool touchScaleChangeAble = DICTOOL->getBooleanValue_json(options, "touchScaleEnable");
|
||||
label->setTouchScaleChangeEnabled(touchScaleChangeAble);
|
||||
const char* text = DICTOOL->getStringValue_json(options, "text");
|
||||
label->setText(text);
|
||||
label->setString(text);
|
||||
bool fs = DICTOOL->checkObjectExist_json(options, "fontSize");
|
||||
if (fs)
|
||||
{
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace cocostudio
|
|||
bool touchScaleChangeAble = DICTOOL->getBooleanValue_json(options, "touchScaleEnable");
|
||||
label->setTouchScaleChangeEnabled(touchScaleChangeAble);
|
||||
const char* text = DICTOOL->getStringValue_json(options, "text");
|
||||
label->setText(text);
|
||||
label->setString(text);
|
||||
bool fs = DICTOOL->checkObjectExist_json(options, "fontSize");
|
||||
if (fs)
|
||||
{
|
||||
|
|
|
@ -89,7 +89,7 @@ bool Text::init(const std::string &textContent, const std::string &fontName, int
|
|||
ret = false;
|
||||
break;
|
||||
}
|
||||
this->setText(textContent);
|
||||
this->setString(textContent);
|
||||
this->setFontName(fontName);
|
||||
this->setFontSize(fontSize);
|
||||
} while (0);
|
||||
|
@ -102,21 +102,22 @@ void Text::initRenderer()
|
|||
addProtectedChild(_labelRenderer, LABEL_RENDERER_Z, -1);
|
||||
}
|
||||
|
||||
void Text::setText(const std::string& text)
|
||||
|
||||
void Text::setString(const std::string &text)
|
||||
{
|
||||
_labelRenderer->setString(text);
|
||||
updateContentSizeWithTextureSize(_labelRenderer->getContentSize());
|
||||
_labelRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
const std::string& Text::getStringValue()
|
||||
|
||||
const std::string& Text::getString() const
|
||||
{
|
||||
return _labelRenderer->getString();
|
||||
}
|
||||
|
||||
ssize_t Text::getStringLength()
|
||||
{
|
||||
return _labelRenderer->getString().size();
|
||||
return _labelRenderer->getStringLength();
|
||||
}
|
||||
|
||||
void Text::setFontSize(int size)
|
||||
|
@ -324,7 +325,7 @@ void Text::copySpecialProperties(Widget *widget)
|
|||
{
|
||||
setFontName(label->_fontName);
|
||||
setFontSize(label->_labelRenderer->getSystemFontSize());
|
||||
setText(label->getStringValue());
|
||||
setString(label->getString());
|
||||
setTouchScaleChangeEnabled(label->_touchScaleChangeEnabled);
|
||||
setTextHorizontalAlignment(label->_labelRenderer->getHorizontalAlignment());
|
||||
setTextVerticalAlignment(label->_labelRenderer->getVerticalAlignment());
|
||||
|
|
|
@ -68,17 +68,21 @@ public:
|
|||
*
|
||||
* @param text string value.
|
||||
*/
|
||||
void setText(const std::string& text);
|
||||
CC_DEPRECATED_ATTRIBUTE void setText(const std::string& text){this->setString(text);}
|
||||
void setString(const std::string& text);
|
||||
|
||||
/**
|
||||
* Gets the string value of label.
|
||||
*
|
||||
* @return text string value.
|
||||
*/
|
||||
const std::string& getStringValue();
|
||||
CC_DEPRECATED_ATTRIBUTE const std::string& getStringValue(){ return this->getString();}
|
||||
const std::string& getString()const;
|
||||
|
||||
/**
|
||||
* Gets the string length of label.
|
||||
* Gets the string length of the label.
|
||||
* Note: This length will be larger than the raw string length,
|
||||
* if you want to get the raw string length, you should call this->getString().size() instead
|
||||
*
|
||||
* @return string length.
|
||||
*/
|
||||
|
|
|
@ -53,19 +53,19 @@ void UIButtonTest::touchEvent(Ref *pSender, Widget::TouchEventType type)
|
|||
switch (type)
|
||||
{
|
||||
case Widget::TouchEventType::BEGAN:
|
||||
_displayValueLabel->setText(String::createWithFormat("Touch Down")->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("Touch Down")->getCString());
|
||||
break;
|
||||
|
||||
case Widget::TouchEventType::MOVED:
|
||||
_displayValueLabel->setText(String::createWithFormat("Touch Move")->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("Touch Move")->getCString());
|
||||
break;
|
||||
|
||||
case Widget::TouchEventType::ENDED:
|
||||
_displayValueLabel->setText(String::createWithFormat("Touch Up")->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("Touch Up")->getCString());
|
||||
break;
|
||||
|
||||
case Widget::TouchEventType::CANCELED:
|
||||
_displayValueLabel->setText(String::createWithFormat("Touch Cancelled")->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("Touch Cancelled")->getCString());
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -125,19 +125,19 @@ void UIButtonTest_Scale9::touchEvent(Ref *pSender, Widget::TouchEventType type)
|
|||
switch (type)
|
||||
{
|
||||
case Widget::TouchEventType::BEGAN:
|
||||
_displayValueLabel->setText(String::createWithFormat("Touch Down")->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("Touch Down")->getCString());
|
||||
break;
|
||||
|
||||
case Widget::TouchEventType::MOVED:
|
||||
_displayValueLabel->setText(String::createWithFormat("Touch Move")->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("Touch Move")->getCString());
|
||||
break;
|
||||
|
||||
case Widget::TouchEventType::ENDED:
|
||||
_displayValueLabel->setText(String::createWithFormat("Touch Up")->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("Touch Up")->getCString());
|
||||
break;
|
||||
|
||||
case Widget::TouchEventType::CANCELED:
|
||||
_displayValueLabel->setText(String::createWithFormat("Touch Cancelled")->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("Touch Cancelled")->getCString());
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -194,19 +194,19 @@ void UIButtonTest_PressedAction::touchEvent(Ref *pSender, Widget::TouchEventType
|
|||
switch (type)
|
||||
{
|
||||
case Widget::TouchEventType::BEGAN:
|
||||
_displayValueLabel->setText(String::createWithFormat("Touch Down")->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("Touch Down")->getCString());
|
||||
break;
|
||||
|
||||
case Widget::TouchEventType::MOVED:
|
||||
_displayValueLabel->setText(String::createWithFormat("Touch Move")->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("Touch Move")->getCString());
|
||||
break;
|
||||
|
||||
case Widget::TouchEventType::ENDED:
|
||||
_displayValueLabel->setText(String::createWithFormat("Touch Up")->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("Touch Up")->getCString());
|
||||
break;
|
||||
|
||||
case Widget::TouchEventType::CANCELED:
|
||||
_displayValueLabel->setText(String::createWithFormat("Touch Cancelled")->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("Touch Cancelled")->getCString());
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -264,19 +264,19 @@ void UIButtonTest_Title::touchEvent(Ref *pSender, Widget::TouchEventType type)
|
|||
switch (type)
|
||||
{
|
||||
case Widget::TouchEventType::BEGAN:
|
||||
_displayValueLabel->setText(String::createWithFormat("Touch Down")->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("Touch Down")->getCString());
|
||||
break;
|
||||
|
||||
case Widget::TouchEventType::MOVED:
|
||||
_displayValueLabel->setText(String::createWithFormat("Touch Move")->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("Touch Move")->getCString());
|
||||
break;
|
||||
|
||||
case Widget::TouchEventType::ENDED:
|
||||
_displayValueLabel->setText(String::createWithFormat("Touch Up")->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("Touch Up")->getCString());
|
||||
break;
|
||||
|
||||
case Widget::TouchEventType::CANCELED:
|
||||
_displayValueLabel->setText(String::createWithFormat("Touch Cancelled")->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("Touch Cancelled")->getCString());
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -50,7 +50,7 @@ bool UIButtonTest_Editor::init()
|
|||
_displayValueLabel = Text::create();
|
||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
||||
_displayValueLabel->setFontSize(30);
|
||||
_displayValueLabel->setText("No event");
|
||||
_displayValueLabel->setString("No event");
|
||||
_displayValueLabel->setPosition(Vector2(_layout->getSize().width / 2,
|
||||
_layout->getSize().height - _displayValueLabel->getSize().height * 1.75f));
|
||||
_touchGroup->addChild(_displayValueLabel);
|
||||
|
@ -66,19 +66,19 @@ void UIButtonTest_Editor::touchEvent(Ref *pSender, Widget::TouchEventType type)
|
|||
switch (type)
|
||||
{
|
||||
case Widget::TouchEventType::BEGAN:
|
||||
_displayValueLabel->setText("Touch Down");
|
||||
_displayValueLabel->setString("Touch Down");
|
||||
break;
|
||||
|
||||
case Widget::TouchEventType::MOVED:
|
||||
_displayValueLabel->setText("Touch Moved");
|
||||
_displayValueLabel->setString("Touch Moved");
|
||||
break;
|
||||
|
||||
case Widget::TouchEventType::ENDED:
|
||||
_displayValueLabel->setText("Touch Ended");
|
||||
_displayValueLabel->setString("Touch Ended");
|
||||
break;
|
||||
|
||||
case Widget::TouchEventType::CANCELED:
|
||||
_displayValueLabel->setText("Touch Canceled");
|
||||
_displayValueLabel->setString("Touch Canceled");
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -53,11 +53,11 @@ void UICheckBoxTest::selectedEvent(Ref* pSender,CheckBox::EventType type)
|
|||
switch (type)
|
||||
{
|
||||
case CheckBox::EventType::SELECTED:
|
||||
_displayValueLabel->setText(String::createWithFormat("Selected")->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("Selected")->getCString());
|
||||
break;
|
||||
|
||||
case CheckBox::EventType::UNSELECTED:
|
||||
_displayValueLabel->setText(String::createWithFormat("Unselected")->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("Unselected")->getCString());
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -40,7 +40,7 @@ bool UICheckBoxTest_Editor::init()
|
|||
_displayValueLabel = Text::create();
|
||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
||||
_displayValueLabel->setFontSize(30);
|
||||
_displayValueLabel->setText("No event");
|
||||
_displayValueLabel->setString("No event");
|
||||
_displayValueLabel->setPosition(Vector2(_layout->getSize().width / 2,
|
||||
_layout->getSize().height - _displayValueLabel->getSize().height * 1.75f));
|
||||
_touchGroup->addChild(_displayValueLabel);
|
||||
|
@ -56,11 +56,11 @@ void UICheckBoxTest_Editor::selectedStateEvent(Ref *pSender, CheckBox::EventType
|
|||
switch (type)
|
||||
{
|
||||
case CheckBox::EventType::UNSELECTED:
|
||||
_displayValueLabel->setText("Unselected");
|
||||
_displayValueLabel->setString("Unselected");
|
||||
break;
|
||||
|
||||
case CheckBox::EventType::SELECTED:
|
||||
_displayValueLabel->setText("Selected");
|
||||
_displayValueLabel->setString("Selected");
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -196,9 +196,9 @@ void UIFocusTestHorizontal::toggleFocusLoop(cocos2d::Ref * pObjc, Widget::TouchE
|
|||
if (type == Widget::TouchEventType::ENDED) {
|
||||
_horizontalLayout->setLoopFocus(!_horizontalLayout->isLoopFocus());
|
||||
if (_horizontalLayout->isLoopFocus()) {
|
||||
_loopText->setText("loop enabled");
|
||||
_loopText->setString("loop enabled");
|
||||
}else{
|
||||
_loopText->setText("loop disabled");
|
||||
_loopText->setString("loop disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -267,9 +267,9 @@ void UIFocusTestVertical::toggleFocusLoop(cocos2d::Ref * pObjc, Widget::TouchEve
|
|||
if (type == Widget::TouchEventType::ENDED) {
|
||||
_verticalLayout->setLoopFocus(!_verticalLayout->isLoopFocus());
|
||||
if (_verticalLayout->isLoopFocus()) {
|
||||
_loopText->setText("loop enabled");
|
||||
_loopText->setString("loop enabled");
|
||||
}else{
|
||||
_loopText->setText("loop disabled");
|
||||
_loopText->setString("loop disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -369,9 +369,9 @@ void UIFocusTestNestedLayout1::toggleFocusLoop(cocos2d::Ref * pObjc, Widget::Tou
|
|||
if (type == Widget::TouchEventType::ENDED) {
|
||||
_verticalLayout->setLoopFocus(!_verticalLayout->isLoopFocus());
|
||||
if (_verticalLayout->isLoopFocus()) {
|
||||
_loopText->setText("loop enabled");
|
||||
_loopText->setString("loop enabled");
|
||||
}else{
|
||||
_loopText->setText("loop disabled");
|
||||
_loopText->setString("loop disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -471,9 +471,9 @@ void UIFocusTestNestedLayout2::toggleFocusLoop(cocos2d::Ref * pObjc, Widget::Tou
|
|||
if (type == Widget::TouchEventType::ENDED) {
|
||||
_horizontalLayout->setLoopFocus(!_horizontalLayout->isLoopFocus());
|
||||
if (_horizontalLayout->isLoopFocus()) {
|
||||
_loopText->setText("loop enabled");
|
||||
_loopText->setString("loop enabled");
|
||||
}else{
|
||||
_loopText->setText("loop disabled");
|
||||
_loopText->setString("loop disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -581,9 +581,9 @@ void UIFocusTestNestedLayout3::toggleFocusLoop(cocos2d::Ref * pObjc, Widget::Tou
|
|||
if (type == Widget::TouchEventType::ENDED) {
|
||||
_verticalLayout->setLoopFocus(!_verticalLayout->isLoopFocus());
|
||||
if (_verticalLayout->isLoopFocus()) {
|
||||
_loopText->setText("loop enabled");
|
||||
_loopText->setString("loop enabled");
|
||||
}else{
|
||||
_loopText->setText("loop disabled");
|
||||
_loopText->setString("loop disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ void UIPageViewTest::pageViewEvent(Ref *pSender, PageView::EventType type)
|
|||
{
|
||||
PageView* pageView = dynamic_cast<PageView*>(pSender);
|
||||
|
||||
_displayValueLabel->setText(CCString::createWithFormat("page = %ld", pageView->getCurPageIndex() + 1)->getCString());
|
||||
_displayValueLabel->setString(CCString::createWithFormat("page = %ld", pageView->getCurPageIndex() + 1)->getCString());
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ static Scene* sceneWithTitle(const char * title) \
|
|||
if (uiLayer && uiLayer->init()) \
|
||||
{ \
|
||||
uiLayer->autorelease(); \
|
||||
uiLayer->getSceneTitle()->setText(title); \
|
||||
uiLayer->getSceneTitle()->setString(title); \
|
||||
pScene->addChild(uiLayer); \
|
||||
} \
|
||||
else \
|
||||
|
|
|
@ -43,7 +43,7 @@ static Scene* sceneWithTitle(const char * title) \
|
|||
if (uiLayer && uiLayer->init()) \
|
||||
{ \
|
||||
uiLayer->autorelease(); \
|
||||
uiLayer->getSceneTitle()->setText(title); \
|
||||
uiLayer->getSceneTitle()->setString(title); \
|
||||
pScene->addChild(uiLayer); \
|
||||
} \
|
||||
else \
|
||||
|
|
|
@ -54,7 +54,7 @@ void UISliderTest::sliderEvent(Ref *pSender, Slider::EventType type)
|
|||
{
|
||||
Slider* slider = dynamic_cast<Slider*>(pSender);
|
||||
int percent = slider->getPercent();
|
||||
_displayValueLabel->setText(String::createWithFormat("Percent %d", percent)->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("Percent %d", percent)->getCString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,6 +112,6 @@ void UISliderTest_Scale9::sliderEvent(Ref *pSender, Slider::EventType type)
|
|||
{
|
||||
Slider* slider = dynamic_cast<Slider*>(pSender);
|
||||
int percent = slider->getPercent();
|
||||
_displayValueLabel->setText(String::createWithFormat("Percent %d", percent)->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("Percent %d", percent)->getCString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ bool UISliderTest_Editor::init()
|
|||
_displayValueLabel = Text::create();
|
||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
||||
_displayValueLabel->setFontSize(30);
|
||||
_displayValueLabel->setText("No event");
|
||||
_displayValueLabel->setString("No event");
|
||||
_displayValueLabel->setPosition(Vector2(_layout->getSize().width / 2,
|
||||
_layout->getSize().height - _displayValueLabel->getSize().height * 1.75f));
|
||||
_touchGroup->addChild(_displayValueLabel);
|
||||
|
@ -63,7 +63,7 @@ void UISliderTest_Editor::sliderEvent(Ref *pSender, Slider::EventType type)
|
|||
case Slider::EventType::ON_PERCENTAGE_CHANGED:
|
||||
{
|
||||
Slider* slider = static_cast<Slider*>(pSender);
|
||||
_displayValueLabel->setText(CCString::createWithFormat("percent %d", slider->getPercent())->getCString());
|
||||
_displayValueLabel->setString(CCString::createWithFormat("percent %d", slider->getPercent())->getCString());
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ void UITextFieldTest::textFieldEvent(Ref *pSender, TextField::EventType type)
|
|||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
textField->runAction(CCMoveTo::create(0.225f,
|
||||
Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2.0f)));
|
||||
_displayValueLabel->setText(String::createWithFormat("attach with IME")->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("attach with IME")->getCString());
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -63,16 +63,16 @@ void UITextFieldTest::textFieldEvent(Ref *pSender, TextField::EventType type)
|
|||
TextField* textField = dynamic_cast<TextField*>(pSender);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
textField->runAction(CCMoveTo::create(0.175f, Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f)));
|
||||
_displayValueLabel->setText(String::createWithFormat("detach with IME")->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("detach with IME")->getCString());
|
||||
}
|
||||
break;
|
||||
|
||||
case TextField::EventType::INSERT_TEXT:
|
||||
_displayValueLabel->setText(String::createWithFormat("insert words")->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("insert words")->getCString());
|
||||
break;
|
||||
|
||||
case TextField::EventType::DELETE_BACKWARD:
|
||||
_displayValueLabel->setText(String::createWithFormat("delete word")->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("delete word")->getCString());
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -132,7 +132,7 @@ void UITextFieldTest_MaxLength::textFieldEvent(Ref *pSender, TextField::EventTyp
|
|||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
textField->runAction(CCMoveTo::create(0.225f,
|
||||
Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2.0f)));
|
||||
_displayValueLabel->setText(String::createWithFormat("attach with IME max length %d", textField->getMaxLength())->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("attach with IME max length %d", textField->getMaxLength())->getCString());
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -141,21 +141,21 @@ void UITextFieldTest_MaxLength::textFieldEvent(Ref *pSender, TextField::EventTyp
|
|||
TextField* textField = dynamic_cast<TextField*>(pSender);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
textField->runAction(CCMoveTo::create(0.175f, Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f)));
|
||||
_displayValueLabel->setText(String::createWithFormat("detach with IME max length %d", textField->getMaxLength())->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("detach with IME max length %d", textField->getMaxLength())->getCString());
|
||||
}
|
||||
break;
|
||||
|
||||
case TextField::EventType::INSERT_TEXT:
|
||||
{
|
||||
TextField* textField = dynamic_cast<TextField*>(pSender);
|
||||
_displayValueLabel->setText(String::createWithFormat("insert words max length %d", textField->getMaxLength())->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("insert words max length %d", textField->getMaxLength())->getCString());
|
||||
}
|
||||
break;
|
||||
|
||||
case TextField::EventType::DELETE_BACKWARD:
|
||||
{
|
||||
TextField* textField = dynamic_cast<TextField*>(pSender);
|
||||
_displayValueLabel->setText(String::createWithFormat("delete word max length %d", textField->getMaxLength())->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("delete word max length %d", textField->getMaxLength())->getCString());
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -216,7 +216,7 @@ void UITextFieldTest_Password::textFieldEvent(Ref *pSender, TextField::EventType
|
|||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
textField->runAction(CCMoveTo::create(0.225f,
|
||||
Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2.0f)));
|
||||
_displayValueLabel->setText(String::createWithFormat("attach with IME password")->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("attach with IME password")->getCString());
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -225,16 +225,16 @@ void UITextFieldTest_Password::textFieldEvent(Ref *pSender, TextField::EventType
|
|||
TextField* textField = dynamic_cast<TextField*>(pSender);
|
||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||
textField->runAction(CCMoveTo::create(0.175f, Vector2(screenSize.width / 2.0f, screenSize.height / 2.0f)));
|
||||
_displayValueLabel->setText(String::createWithFormat("detach with IME password")->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("detach with IME password")->getCString());
|
||||
}
|
||||
break;
|
||||
|
||||
case TextField::EventType::INSERT_TEXT:
|
||||
_displayValueLabel->setText(String::createWithFormat("insert words password")->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("insert words password")->getCString());
|
||||
break;
|
||||
|
||||
case TextField::EventType::DELETE_BACKWARD:
|
||||
_displayValueLabel->setText(String::createWithFormat("delete word password")->getCString());
|
||||
_displayValueLabel->setString(String::createWithFormat("delete word password")->getCString());
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -300,7 +300,7 @@ void UITextFieldTest_LineWrap::textFieldEvent(Ref *pSender, TextField::EventType
|
|||
textField->setTextHorizontalAlignment(TextHAlignment::LEFT);
|
||||
textField->setTextVerticalAlignment(TextVAlignment::TOP);
|
||||
|
||||
_displayValueLabel->setText(CCString::createWithFormat("attach with IME")->getCString());
|
||||
_displayValueLabel->setString(CCString::createWithFormat("attach with IME")->getCString());
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -312,16 +312,16 @@ void UITextFieldTest_LineWrap::textFieldEvent(Ref *pSender, TextField::EventType
|
|||
textField->setTextHorizontalAlignment(TextHAlignment::CENTER);
|
||||
textField->setTextVerticalAlignment(TextVAlignment::CENTER);
|
||||
|
||||
_displayValueLabel->setText(CCString::createWithFormat("detach with IME")->getCString());
|
||||
_displayValueLabel->setString(CCString::createWithFormat("detach with IME")->getCString());
|
||||
}
|
||||
break;
|
||||
|
||||
case TextField::EventType::INSERT_TEXT:
|
||||
_displayValueLabel->setText(CCString::createWithFormat("insert words")->getCString());
|
||||
_displayValueLabel->setString(CCString::createWithFormat("insert words")->getCString());
|
||||
break;
|
||||
|
||||
case TextField::EventType::DELETE_BACKWARD:
|
||||
_displayValueLabel->setText(CCString::createWithFormat("delete word")->getCString());
|
||||
_displayValueLabel->setString(CCString::createWithFormat("delete word")->getCString());
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -46,7 +46,7 @@ bool UITextFieldTest_Editor::init()
|
|||
_displayValueLabel = Text::create();
|
||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
||||
_displayValueLabel->setFontSize(30);
|
||||
_displayValueLabel->setText("No event");
|
||||
_displayValueLabel->setString("No event");
|
||||
_displayValueLabel->setPosition(Vector2(_layout->getSize().width / 2,
|
||||
_layout->getSize().height - _displayValueLabel->getSize().height * 1.75f));
|
||||
_touchGroup->addChild(_displayValueLabel);
|
||||
|
@ -62,19 +62,19 @@ void UITextFieldTest_Editor::textFieldEvent(Ref *pSender, TextField::EventType t
|
|||
switch (type)
|
||||
{
|
||||
case TextField::EventType::ATTACH_WITH_IME:
|
||||
_displayValueLabel->setText("attach with IME");
|
||||
_displayValueLabel->setString("attach with IME");
|
||||
break;
|
||||
|
||||
case TextField::EventType::DETACH_WITH_IME:
|
||||
_displayValueLabel->setText("detach with IME");
|
||||
_displayValueLabel->setString("detach with IME");
|
||||
break;
|
||||
|
||||
case TextField::EventType::INSERT_TEXT:
|
||||
_displayValueLabel->setText("insert words");
|
||||
_displayValueLabel->setString("insert words");
|
||||
break;
|
||||
|
||||
case TextField::EventType::DELETE_BACKWARD:
|
||||
_displayValueLabel->setText("delete word");
|
||||
_displayValueLabel->setString("delete word");
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -22,7 +22,7 @@ bool UIWidgetAddNodeTest::init()
|
|||
|
||||
// Add the alert
|
||||
Text* alert = Text::create();
|
||||
alert->setText("Widget Add Node");
|
||||
alert->setString("Widget Add Node");
|
||||
alert->setFontName("fonts/Marker Felt.ttf");
|
||||
alert->setFontSize(30);
|
||||
alert->setColor(Color3B(159, 168, 176));
|
||||
|
|
Loading…
Reference in New Issue