Track(TrackInfo *trackInfo) : BaseTrack((BaseTrackInfo *) trackInfo) { _trackInfo = trackInfo; _exHandleL = new Sprite; _exHandleR = new Sprite; _exHandleL->setSize(35, 50); _exHandleR->setSize(35, 50); _exHandleL->isInteractive = true; _exHandleR->isInteractive = true; addChild(_exHandleL); addChild(_exHandleR); add_event(MouseEvent::UP, onUp); add_event_on_context(MouseEvent::UP, onUp) setColor(52, 52, 52); TextField *input = new TextField; input->setText("lllll"); input->move(5, 28); addChild(input); TextField *input2 = new TextField; input2->setText("wwwww"); input2->move(5, 40); addChild(input2); }
fresult YNDialogForm::ShowYNDialog(char* dialogName, char* formTitle, char* formSubtitle, char* msgTitle, char* msgContent, char* yesText) { fresult fres; _TitleText = formTitle; _SubtitleText = formSubtitle; _dialogName = dialogName; uword_t headerLen = Length(msgTitle); fres = _txtHeader->SetText(msgTitle); ENSURESUCCESS(fres); Size sz = _App->GetClientAreaSize(); fres = HCenterTextField(_txtHeader, CenterHorizontaly, headerLen, sz.Width, 0); ENSURESUCCESS(fres); fres = _txtContent->SetText(msgContent); ENSURESUCCESS(fres); TextField* tf = _miYes->GetTextField(); if (tf!=NULL) { fres = tf->SetText(yesText); ENSURESUCCESS(fres); uword_t yesTextLen = Length(yesText); HCenterTextField(tf, ToRight, yesTextLen, sz.Width, 8); } fres = _FormManager->ShowForm(GetName()); ENSURESUCCESS(fres); return SUCCESS; }
bool UITextFieldTest_TrueTypeFont::init() { if (UIScene::init()) { Size widgetSize = _widget->getContentSize(); // Add a label in which the textfield events will be displayed _displayValueLabel = Text::create("True Type Font Test - No Event","fonts/Marker Felt.ttf",32); _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); // Add the alert Text* alert = Text::create("TextField","fonts/Marker Felt.ttf",30); alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f)); _uiLayer->addChild(alert); // Create the textfield TextField* textField = TextField::create("input words here","fonts/A Damn Mess.ttf",30); textField->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); textField->addEventListener(CC_CALLBACK_2(UITextFieldTest_TrueTypeFont::textFieldEvent, this)); _uiLayer->addChild(textField); return true; } return false; }
TextField *SimpleGui::addTextField(string name, string &value) { TextField *field = (TextField*)INSTANTIATE_WITH_ID("textfield", name); field->pointToValue(&value); field->width = SIMPLE_GUI_WIDTH; gui->addChild(field); return field; }
// Positive test for the text-changed signal. int utcDaliTextFieldTextChangedP(void) { ToolkitTestApplication application; tet_infoline(" utcDaliTextFieldTextChangedP"); TextField field = TextField::New(); DALI_TEST_CHECK( field ); Stage::GetCurrent().Add( field ); field.TextChangedSignal().Connect(&TestTextChangedCallback); gTextChangedCallBackCalled = false; field.SetProperty( TextField::Property::TEXT, "ABC" ); DALI_TEST_CHECK( gTextChangedCallBackCalled ); application.SendNotification(); field.SetKeyInputFocus(); gTextChangedCallBackCalled = false; application.ProcessEvent( GenerateKey( "D", "D", 0, 0, 0, Integration::KeyEvent::Down ) ); DALI_TEST_CHECK( gTextChangedCallBackCalled ); END_TEST; }
void UITextFieldTest::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")->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")->getCString()); } break; case TextField::EventType::INSERT_TEXT: _displayValueLabel->setString(String::createWithFormat("insert words")->getCString()); break; case TextField::EventType::DELETE_BACKWARD: _displayValueLabel->setString(String::createWithFormat("delete word")->getCString()); break; default: break; } }
bool UITextFieldTest_MaxLength::init() { if (UIScene::init()) { Size screenSize = CCDirector::getInstance()->getWinSize(); // Add a label in which the textfield events will be displayed _displayValueLabel = Text::create("No Event","fonts/Marker Felt.ttf",32); _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); _displayValueLabel->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f)); _uiLayer->addChild(_displayValueLabel); // Add the alert Text *alert = Text::create("TextField max length","fonts/Marker Felt.ttf",30); alert->setColor(Color3B(159, 168, 176)); alert->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f - alert->getContentSize().height * 3.075f)); _uiLayer->addChild(alert); // Create the textfield TextField* textField = TextField::create("input words here","Arial",30); textField->setMaxLengthEnabled(true); textField->setMaxLength(3); textField->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f)); textField->addEventListener(CC_CALLBACK_2(UITextFieldTest_MaxLength::textFieldEvent, this)); _uiLayer->addChild(textField); return true; } return false; }
// Positive Atlas Text Renderer test int utcDaliTextFieldAtlasRenderP(void) { ToolkitTestApplication application; tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP"); StyleManager styleManager = StyleManager::Get(); styleManager.RequestDefaultTheme(); TextField field = TextField::New(); DALI_TEST_CHECK( field ); field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); Stage::GetCurrent().Add( field ); try { // Render some text with the shared atlas backend field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS ); application.SendNotification(); application.Render(); } catch( ... ) { tet_result(TET_FAIL); } END_TEST; }
static int lua_cocos2dx_TextField_addEventListenerTextField(lua_State* L) { if (nullptr == L) return 0; int argc = 0; TextField* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast<TextField*>(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_TextField_addEventListenerTextField'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) { goto tolua_lerror; } #endif LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); if (nullptr == listener) { tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); return 0; } LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); self->setUserObject(listener); self->addEventListenerTextField(listener, textfieldeventselector(LuaCocoStudioEventListener::eventCallbackFunc)); return 0; } CCLOG("'addEventListenerTextField' function of TextField has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'addEventListenerTextField'.",&tolua_err); return 0; #endif }
bool UITextFieldTest_LineWrap::init() { if (UIScene::init()) { Size widgetSize = _widget->getContentSize(); // Add a label in which the textfield events will be displayed _displayValueLabel = Text::create("No Event","fonts/Marker Felt.ttf",30); _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1)); _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5)); _uiLayer->addChild(_displayValueLabel); // Add the alert Text *alert = Text::create("TextField line wrap","fonts/Marker Felt.ttf",30); alert->setColor(Color3B(159, 168, 176)); alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075)); _uiLayer->addChild(alert); // Create the textfield TextField* textField = TextField::create("input words here","fonts/Marker Felt.ttf",30); textField->ignoreContentAdaptWithSize(false); ((Label*)(textField->getVirtualRenderer()))->setLineBreakWithoutSpace(true); textField->setContentSize(Size(240, 170)); textField->setString("input words here"); textField->setTextHorizontalAlignment(TextHAlignment::CENTER); textField->setTextVerticalAlignment(TextVAlignment::CENTER); textField->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); textField->addEventListener(CC_CALLBACK_2(UITextFieldTest_LineWrap::textFieldEvent, this)); _uiLayer->addChild(textField); return true; } return false; }
TextField* TextField::create() { TextField* widget = new TextField(); if (widget && widget->init()) { CC_SAFE_AUTORELEASE(widget); return widget; } CC_SAFE_DELETE(widget); return NULL; }
TextField* TextField::create() { TextField* widget = new TextField(); if (widget && widget->init()) { widget->autorelease(); return widget; } CC_SAFE_DELETE(widget); return NULL; }
TextField* TextField::create() { TextField* widget = new (std::nothrow) TextField(); if (widget && widget->init()) { widget->autorelease(); return widget; } CC_SAFE_DELETE(widget); return nullptr; }
int UtcDaliToolkitTextFieldAssignmentOperatorP(void) { ToolkitTestApplication application; tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP"); TextField textField = TextField::New(); textField.SetProperty( TextField::Property::TEXT, "Test" ); TextField copy = textField; DALI_TEST_CHECK( copy ); DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) ); END_TEST; }
int UtcDaliToolkitTextFieldCopyConstructorP(void) { ToolkitTestApplication application; tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP"); TextField textField = TextField::New(); textField.SetProperty( TextField::Property::TEXT, "Test" ); TextField copy( textField ); DALI_TEST_CHECK( copy ); DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) ); END_TEST; }
void ApplicationUI::login(){ Login *login = new Login(); TextField *emailText = navPane->findChild<TextField*>("emailText"); TextField *passwordText = navPane->findChild<TextField*>("passwordText"); bool res = QObject::connect(login, SIGNAL(userLoggedIn()), this, SLOT(handleUserLoggedIn())); Q_ASSERT(res); Q_UNUSED(res); login->loginUser(emailText->text(), passwordText->text()); }
static int lua_cocos2dx_TextField_addEventListener(lua_State* L) { if (nullptr == L) return 0; int argc = 0; TextField* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast<TextField*>(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_TextField_addEventListener'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) { goto tolua_lerror; } #endif LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); self->addEventListener([=](cocos2d::Ref* ref,TextField::EventType eventType){ handleUIEvent(handler, ref, (int)eventType); }); ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler); return 0; } luaL_error(L, "'addEventListener' function of TextField has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'addEventListener'.",&tolua_err); return 0; #endif }
void TextFieldReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options) { WidgetReader::setPropsFromJsonDictionary(widget, options); TextField* textField = static_cast<TextField*>(widget); bool ph = DICTOOL->checkObjectExist_json(options, P_PlaceHolder); if (ph) { textField->setPlaceHolder(DICTOOL->getStringValue_json(options, P_PlaceHolder,"input words here")); } textField->setText(DICTOOL->getStringValue_json(options, P_Text,"Text Tield")); textField->setFontSize(DICTOOL->getIntValue_json(options, P_FontSize,20)); textField->setFontName(DICTOOL->getStringValue_json(options, P_FontName,"微软雅黑")); bool tsw = DICTOOL->checkObjectExist_json(options, P_TouchSizeWidth); bool tsh = DICTOOL->checkObjectExist_json(options, P_TouchSizeHeight); if (tsw && tsh) { textField->setTouchSize(Size(DICTOOL->getFloatValue_json(options, P_TouchSizeWidth), DICTOOL->getFloatValue_json(options,P_TouchSizeHeight))); } // float dw = DICTOOL->getFloatValue_json(options, "width"); // float dh = DICTOOL->getFloatValue_json(options, "height"); // if (dw > 0.0f || dh > 0.0f) // { // //textField->setSize(Size(dw, dh)); // } bool maxLengthEnable = DICTOOL->getBooleanValue_json(options, P_MaxLengthEnable); textField->setMaxLengthEnabled(maxLengthEnable); if (maxLengthEnable) { int maxLength = DICTOOL->getIntValue_json(options, P_MaxLength,10); textField->setMaxLength(maxLength); } bool passwordEnable = DICTOOL->getBooleanValue_json(options, P_PasswordEnable); textField->setPasswordEnabled(passwordEnable); if (passwordEnable) { textField->setPasswordStyleText(DICTOOL->getStringValue_json(options, P_PasswordStyleText,"*")); } WidgetReader::setColorPropsFromJsonDictionary(widget, options); }
static void test_TextField_backspace_ime_on() { TextField* t = createTextField(); toggleIme(t); keyPress(t, 'a'); keyPress(t, 'i'); keyPress(t, KeyEvent::VKEY_BACKSPACE); EXPECT_EQ(0, t->getCursor()); EXPECT_STR_EQ("", t->getText()); keyPress(t, KeyEvent::VKEY_ENTER); EXPECT_EQ_TEXT_FIELD("あ", 1, t); destroyTextField(t); }
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; } }
void Win32Painter::Create(Widget *w) { Button *button; Static *label; TextField *textField; HINSTANCE inst = (HINSTANCE)GetWindowLong(parent_, GWL_HINSTANCE); if ((button=dynamic_cast<Button*>(w))) { hwnd_ = CreateWindow("BUTTON",button->Label().c_str(),WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,button->X(),button->Y(),button->Width(),button->Height(),parent_,NULL,inst,NULL); } else if ((label=dynamic_cast<Static*>(w))) { hwnd_ = CreateWindow("STATIC",label->Label().c_str(),WS_CHILD|WS_VISIBLE|SS_LEFT,label->X(),label->Y(),label->Width(),label->Height(),parent_,NULL,inst,NULL); } else if ((textField=dynamic_cast<TextField*>(w))) { hwnd_ = CreateWindow("EDIT",textField->Text().c_str(),WS_CHILD|WS_VISIBLE|ES_LEFT|ES_AUTOHSCROLL|WS_BORDER,textField->X(),textField->Y(),textField->Width(),textField->Height(),parent_,NULL,inst,NULL); } originalWndProc_ = (WNDPROC)SetWindowLong(hwnd_, GWL_WNDPROC, (LONG)WndProc); SetWindowLong(hwnd_, GWL_USERDATA, (LONG)w); }
bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue ) { bool result = false; Property::Map imageMap; imageMap[mapKey] =mapValue; field.SetProperty( property , imageMap ); Property::Value propValue = field.GetProperty( property ); Property::Map* resultMap = propValue.GetMap(); if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue ) { result = true; } return result; }
// Negative test for the text-changed signal. int utcDaliTextFieldTextChangedN(void) { ToolkitTestApplication application; tet_infoline(" utcDaliTextFieldTextChangedN"); TextField field = TextField::New(); DALI_TEST_CHECK( field ); Stage::GetCurrent().Add( field ); field.TextChangedSignal().Connect(&TestTextChangedCallback); gTextChangedCallBackCalled = false; field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT DALI_TEST_CHECK( !gTextChangedCallBackCalled ); END_TEST; }
static void test_TextField_ime_on() { TextField* t = createTextField(); EXPECT_EQ(false, t->isImeOn()); toggleIme(t); EXPECT_TRUE(t->isImeOn()); keyPress(t, 'a'); keyPress(t, KeyEvent::VKEY_ENTER); EXPECT_STR_EQ("あ", t->getText()); // japanese hiragana A keyPress(t, 'i'); keyPress(t, 'u'); keyPress(t, KeyEvent::VKEY_ENTER); EXPECT_STR_EQ("あいう", t->getText()); // japanese hiragana A I U destroyTextField(t); }
static int tolua_Cocos2dx_TextField_addEventListenerTextField00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"TextField",0,&tolua_err) || !toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { TextField* self = (TextField*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addEventListenerTextField'", NULL); #endif LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); if (NULL == listener) { tolua_error(tolua_S,"LuaCocoStudioEventListener create fail\n", NULL); return 0; } LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0)); listener->setHandler(handler); CCDictionary* dict = static_cast<CCDictionary*>(self->getScriptObjectDict()); if (NULL == dict) { dict = CCDictionary::create(); self->setScriptObjectDict(dict); } dict->setObject(listener, "textfieldEventListener"); self->addEventListenerTextField(listener, textfieldeventselector(LuaCocoStudioEventListener::eventCallbackFunc)); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'addEventListenerTextField'.",&tolua_err); return 0; #endif }
static void test_TextField_backspace_empty_ime_on() { TextField* t = createTextField(); keyPress(t, 'a'); keyPress(t, 'b'); toggleIme(t); keyPress(t, 'a'); keyPress(t, KeyEvent::VKEY_BACKSPACE); EXPECT_EQ(2, t->getCursor()); EXPECT_STR_EQ("ab", t->getText()); // When ime buffer is empty, backspace goes to Textfield keyPress(t, KeyEvent::VKEY_BACKSPACE); EXPECT_EQ(1, t->getCursor()); EXPECT_STR_EQ("a", t->getText()); destroyTextField(t); }
void TextField::copySpecialProperties(Widget *widget) { TextField* textField = dynamic_cast<TextField*>(widget); if (textField) { setText(textField->getStringValue()); setPlaceHolder(textField->getPlaceHolder()); setFontSize(textField->_textFieldRenderer->getFontSize()); setFontName(textField->_textFieldRenderer->getFontName()); 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()); } }
static void test_TextField_remove_multi_byte_backspace() { TextField* t = createTextField(); toggleIme(t); keyPress(t, 'a'); keyPress(t, 'i'); keyPress(t, KeyEvent::VKEY_ENTER); EXPECT_EQ_TEXT_FIELD("あい", 2, t); toggleIme(t); keyPress(t, KeyEvent::VKEY_BACKSPACE); EXPECT_EQ(1, t->getCursor()); EXPECT_STR_EQ("あ", t->getText()); // keyPress(t, KeyEvent::VKEY_BACKSPACE); // EXPECT_EQ(0, t->getCursor()); // EXPECT_STR_EQ("", t->getText()); destroyTextField(t); }
fresult xScatteredMenu::CreateTextField( char* str, Size size, Position position, TextFormat* format, TextField** opTextField, Size buffSize) { fresult fres = SUCCESS; TextField* tf = new TextField(); *opTextField = tf; char* buff = new char[buffSize.Height*buffSize.Width]; tf->Init(size, position, buff, buffSize, (IRender*)_renderer); tf->SetWordWrap(FALSE); tf->SetTextFormat(format); fres = tf->SetText(str); if (fres!=SUCCESS) { return fres; } return SUCCESS; }
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; } }