示例#1
0
void HelloWorld::textFieldEvent(Ref *pSender, TextField::EventType type)
{
	TextField* text;
	std::string sendText;
	switch (type)
	{
	// Sau khi dong IME lai
	case TextField::EventType::DETACH_WITH_IME:
		text = (TextField*)pSender;

		//text = dynamic_cast<TextField*>(pSender);
		
		// Gui du lieu tu client len server
		sendText = "[{\"value\":\"" + text->getStringValue() + "\"}]";
		_client->emit("hello", sendText);

		addTalkPlayer(text->getStringValue());

		break;
	default:
		break;
	}
}
void HelloWorld::GetLoginText(cocos2d::CCObject *obj, TouchEventType eventType)
{
	switch (eventType)
	{
	case TOUCH_EVENT_ENDED:
		 {
			 ul = (UILayer*)this->getChildByTag(10026);
			 TextField* LoginText = dynamic_cast<TextField*>(ul->getWidgetByName("name_TextField"));
			 string text = LoginText->getStringValue();
			 CCLOG("login text = %s",text.c_str());
		 }
		 break;
	default:
		break;
	}
}
示例#3
0
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 HelloWorld::textInput(Object* object,TextFiledEventType type)
{
    switch (type) {
    case TEXTFIELD_EVENT_DETACH_WITH_IME:
    {
        TextField* textField = dynamic_cast<TextField*>(object);
        std::string words = textField->getStringValue();
        TextBMFont* label = dynamic_cast<TextBMFont*>(textField->getParent()->getChildByTag(100));
        label->setText(words.c_str());
        textField->setText("");

        UserDefault::getInstance()->setStringForKey("userStr", words);
        UserDefault::getInstance()->flush();
    }
    break;

    default:
        break;
    }
}