void TextField::copySpecialProperties(Widget *widget) { TextField* textField = dynamic_cast<TextField*>(widget); if (textField) { setText(textField->_textFieldRenderer->getString()); setPlaceHolder(textField->getStringValue()); setFontSize(textField->_textFieldRenderer->getFontSize()); setFontName(textField->_textFieldRenderer->getFontName().c_str()); setMaxLengthEnabled(textField->isMaxLengthEnabled()); setMaxLength(textField->getMaxLength()); setPasswordEnabled(textField->isPasswordEnabled()); setPasswordStyleText(textField->_passwordStyleText.c_str()); setAttachWithIME(textField->getAttachWithIME()); setDetachWithIME(textField->getDetachWithIME()); setInsertText(textField->getInsertText()); setDeleteBackward(textField->getDeleteBackward()); } }
void TextField::copySpecialProperties(Widget *widget) { TextField* textField = dynamic_cast<TextField*>(widget); if (textField) { setString(textField->_textFieldRenderer->getString()); setPlaceHolder(textField->getString()); setFontSize(textField->_fontSize); setFontName(textField->_fontName); setMaxLengthEnabled(textField->isMaxLengthEnabled()); setMaxLength(textField->getMaxLength()); setPasswordEnabled(textField->isPasswordEnabled()); setPasswordStyleText(textField->_passwordStyleText.c_str()); setAttachWithIME(textField->getAttachWithIME()); setDetachWithIME(textField->getDetachWithIME()); setInsertText(textField->getInsertText()); setDeleteBackward(textField->getDeleteBackward()); _eventCallback = textField->_eventCallback; _textFieldEventListener = textField->_textFieldEventListener; _textFieldEventSelector = textField->_textFieldEventSelector; } }
void UITextFieldTest_MaxLength::textFieldEvent(Ref *pSender, TextField::EventType type) { switch (type) { case TextField::EventType::ATTACH_WITH_IME: { TextField* textField = dynamic_cast<TextField*>(pSender); Size screenSize = CCDirector::getInstance()->getWinSize(); textField->runAction(CCMoveTo::create(0.225f, Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2.0f))); _displayValueLabel->setString(String::createWithFormat("attach with IME max length %d", textField->getMaxLength())->getCString()); } break; case TextField::EventType::DETACH_WITH_IME: { TextField* textField = dynamic_cast<TextField*>(pSender); Size screenSize = CCDirector::getInstance()->getWinSize(); textField->runAction(CCMoveTo::create(0.175f, Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f))); _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->setString(String::createWithFormat("insert words max length %d", textField->getMaxLength())->getCString()); } break; case TextField::EventType::DELETE_BACKWARD: { TextField* textField = dynamic_cast<TextField*>(pSender); _displayValueLabel->setString(String::createWithFormat("delete word max length %d", textField->getMaxLength())->getCString()); } break; default: break; } }