本文整理汇总了C++中CCEditBox::setReturnType方法的典型用法代码示例。如果您正苦于以下问题:C++ CCEditBox::setReturnType方法的具体用法?C++ CCEditBox::setReturnType怎么用?C++ CCEditBox::setReturnType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCEditBox
的用法示例。
在下文中一共展示了CCEditBox::setReturnType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initTopMenu
bool CCLobbyView::initTopMenu()
{
CCDirector* director = CCDirector::sharedDirector();
const CCSize winSize = director->getWinSize();
const CCSize mySize = this->getContentSize();
const CCPoint center = ccpMult( ccpFromSize( mySize ), 0.5f );
CCLabelTTF* consoleLabel = CCLabelTTF::create( "disconnected", "Arial", FONT_SIZE(24), CCSizeMake( winSize.width, FONT_SIZE(24) ), kCCTextAlignmentCenter );
consoleLabel->setColor( ccc3(255, 255, 255) );
CCMenuItemLabel* consoleItem = CCMenuItemLabel::create( consoleLabel );
// bottom
const CCSize editSize = CCSizeMake( winSize.width, FONT_SIZE(48) );
CCMenuItem* editItem = CCMenuItem::create();
editItem->setContentSize( editSize );
CCMenu* topMenu = CCMenu::create( consoleItem, editItem, NULL );
if( topMenu )
{
this->setConsole( consoleLabel );
topMenu->alignItemsVertically();
topMenu->setPosition( CCPointMake( center.x, winSize.height - (editItem->getContentSize().height + consoleItem->getContentSize().height)/2 ) );
this->addChild( topMenu, 0, Child::CCMenu_topMenu );
const CCPoint editItemPosition = editItem->getParent()->convertToWorldSpace( editItem->getPosition() );
editItem->setContentSize( winSize );
editItem->ignoreAnchorPointForPosition( false );
editItem->setAnchorPoint( ccp( 0.5f, (winSize.height / (editItemPosition.y - winSize.height)) * 0.5f ) );
CCScale9Sprite* editSprite = CCScale9Sprite::create("extensions/yellow_edit.png");
CCEditBox* edit = CCEditBox::create( editSize, editSprite );
edit->setPlaceHolder("PlayerName");
edit->setReturnType(kKeyboardReturnTypeDone);
edit->setFontColor(ccGRAY);
edit->setMaxLength( 20 );
edit->setDelegate(this);
edit->setTouchEnabled( true );
edit->setPosition( editItemPosition );
CocosNetworkLogic* network = CocosNetworkLogic::getInstance();
JString userName = network->getUserName();
edit->setText(userName.UTF8Representation().cstr());
this->addChild( edit );
this->setEditName(edit);
}
return topMenu;
}
示例2: init
bool TweetScene::init()
{
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCSize editBoxSize = CCSizeMake(visibleSize.width/2, 50);
CCEditBox* editBox = CCEditBox::create(editBoxSize, CCScale9Sprite::create("9patch.png"));
editBox->setPosition(ccp(visibleSize.width/2, visibleSize.height/2));
editBox->setFontColor(ccWHITE);
editBox->setPlaceHolder("TextBox");
editBox->setReturnType(kKeyboardReturnTypeDone);
editBox->setTag(1);
this->addChild(editBox);
CCLabelTTF* tweetLabel = CCLabelTTF::create("つぶやく", "arial", 48);
CCMenuItemLabel* tweetItem = CCMenuItemLabel::create(tweetLabel, this, menu_selector(TweetScene::tweet));
tweetItem->setPosition(ccp(visibleSize.width/2,visibleSize.height-tweetLabel->getContentSize().height));
CCMenu* tweetMenu = CCMenu::create(tweetItem,NULL);
tweetMenu->setPosition(CCPointZero);
this->addChild(tweetMenu);
return true;
}
示例3: LogInTableDraw
void LogInScene::LogInTableDraw(int _index){
CCMenu* popUpMenu = (CCMenu*)popUpMenuLayer->getChildByTag(998);
CCMenu* beginMenu = (CCMenu*)this->getChildByTag(997);
popUpMenu->setTouchEnabled(false);
if (beginMenu!=NULL)
beginMenu->setTouchEnabled(false);
//1.基本层
AccountLayer = CCLayer::create();
AccountLayer->setPosition(CCPointZero);
addChild(AccountLayer,10);
//2.黑色遮罩:不在该移动层上
CCLayerColor* black = CCLayerColor::create(ccc4(0, 0, 0, 155));
black->setPosition(CCPointZero);
AccountLayer->addChild(black,0);
//3.木板
CCSprite* LogInTable = CCSprite::createWithSpriteFrameName("LogInTable.png");
LogInTable->setPosition(ccp(size.width/2, size.height/2+winDif*2));
AccountLayer->addChild(LogInTable,1);
//3.edit box - user name
CCScale9Sprite *UserNameTexture = CCScale9Sprite::createWithSpriteFrameName("textTable.png");
CCEditBox *UserNameBox=CCEditBox::create(CCSizeMake(195, 44), UserNameTexture);
UserNameBox->setPosition(ccp(size.width*8/15, size.height*0.561+winDif*2));
UserNameBox->setFontName("Arial Rounded MT bold");
UserNameBox->setMaxLength(20);
UserNameBox->setInputMode(kEditBoxInputModeAny);
UserNameBox->setInputFlag(kEditBoxInputFlagSensitive);
UserNameBox->setReturnType(kKeyboardReturnTypeDone);
UserNameBox->setDelegate(this);
AccountLayer->addChild(UserNameBox,2,10);
//4.edit box - password
CCScale9Sprite *PasswordTexture = CCScale9Sprite::createWithSpriteFrameName("textTable.png");
CCEditBox *PasswordBox = CCEditBox::create(CCSizeMake(195, 44), PasswordTexture);
PasswordBox->setPosition(ccp(size.width*8/15, size.height*0.486+winDif*2));
PasswordBox->setFontName("Arial Rounded MT bold");
PasswordBox->setMaxLength(50);
PasswordBox->setInputMode(kEditBoxInputModeAny);
PasswordBox->setInputFlag(kEditBoxInputFlagPassword);
PasswordBox->setReturnType(kKeyboardReturnTypeDone);
PasswordBox->setDelegate(this);
AccountLayer->addChild(PasswordBox,2,11);
//5.登录注册按钮
CCMenuItemSprite* Item1;
if (_index == 0){
CCSprite* item1Sprite = CCSprite::createWithSpriteFrameName("signUpButtonGreen.png");
CCSprite* item1Sprite_s = CCSprite::createWithSpriteFrameName("signUpButtonGreen-s.png");
Item1 = CCMenuItemSprite::create(item1Sprite,item1Sprite_s,this,menu_selector(LogInScene::SignUpHTTP));
}
else if (_index == 1){
CCSprite* item1Sprite = CCSprite::createWithSpriteFrameName("binding.png");
CCSprite* item1Sprite_s = CCSprite::createWithSpriteFrameName("binding-s.png");
Item1 = CCMenuItemSprite::create(item1Sprite,item1Sprite_s,this,menu_selector(LogInScene::bindUserAccountHTTP));
}
else if (_index == 2){
CCSprite* item1Sprite = CCSprite::createWithSpriteFrameName("LogInButton.png");
CCSprite* item1Sprite_s = CCSprite::createWithSpriteFrameName("LogInButton-s.png");
Item1 = CCMenuItemSprite::create(item1Sprite,item1Sprite_s,this,menu_selector(LogInScene::LogInHTTP));
}
CCSprite* item2Sprite = CCSprite::createWithSpriteFrameName("cancelButton.png");
CCSprite* item2Sprite_s = CCSprite::createWithSpriteFrameName("cancelButton-s.png");
CCMenuItemSprite* Item2 = CCMenuItemSprite::create(item2Sprite,item2Sprite_s,this,menu_selector(LogInScene::closeThisLayer));
Item1->setPosition(ccp(winSize.width*11.5/30,size.height*0.42+winDif*2));
Item2->setPosition(ccp(winSize.width*18.5/30,size.height*0.42+winDif*2));
CCMenu* LogInMenu = CCMenu::create(Item1,Item2,NULL);
LogInMenu->setPosition(CCPointZero);
AccountLayer->addChild(LogInMenu,3);
}
示例4: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCScale9Sprite* sacel9SprY = CCScale9Sprite::create("[email protected]");
CCEditBox* box = CCEditBox::create(CCSizeMake(200, 80), sacel9SprY);
//设置编辑框内的文字
// box->setText("xcc");
//设置位置
box->setPosition(ccp(200, 200));
//获取编辑框内的文字
CCLOG("Text:%s",box->getText());
box->setDelegate(this);
//设置文本的颜色
box->setFontColor(ccc3(255, 0, 0));
//当编辑框中没有任何字符的提示
box->setPlaceHolder("请输入账号:");
//最大输入文本长度
box->setMaxLength(3);
box->setInputMode(kEditBoxInputModeAny);
// kEditBoxInputModeAny: 开启任何文本的输入键盘,包括换行
// kEditBoxInputModeEmailAddr: 开启 邮件地址 输入类型键盘
// kEditBoxInputModeNumeric: 开启 数字符号 输入类型键盘
// kEditBoxInputModePhoneNumber: 开启 电话号码 输入类型键盘
// kEditBoxInputModeUrl: 开启 URL 输入类型键盘
// kEditBoxInputModeDecimal: 开启 数字 输入类型键盘,允许小数点
// kEditBoxInputModeSingleLine: 开启任何文本的输入键盘,不包括换行
box->setReturnType(kKeyboardReturnTypeSearch);
// kKeyboardReturnTypeDefault: 默认使用键盘return 类型
// kKeyboardReturnTypeDone: 默认使用键盘return类型为“Done”字样
// kKeyboardReturnTypeSend: 默认使用键盘return类型为“Send”字样
// kKeyboardReturnTypeSearch: 默认使用键盘return类型为“Search”字样
// kKeyboardReturnTypeGo: 默认使用键盘return类型为“Go”字样
//设置该属性输入密码时为替代符
box->setInputFlag(kEditBoxInputFlagPassword);
this->addChild(box);
return true;
}
示例5: init
//.........这里部分代码省略.........
this->setConnectButton( button );
label = CCLabelTTF::create( "Create Room", "fonts/American Typewriter.ttf", fontSize );
label->setColor( ccc3( 0, 0, 0 ) );
sprite = CCScale9Sprite::create("Images/r1.png", rect, rect );
sprite->setScaleX( 1.4f );
sprite->setScaleY( 0.8f );
button = CCControlButton::create( label, sprite );
button->addTargetWithActionForControlEvents( this, cccontrol_selector( CCLobbyView::createGameButtonCallback ), CCControlEventTouchUpInside);
button->setPreferredSize( rect.size );
position = center;
position.y -= 136;
//position.x += 0;
button->setPosition( position );
this->setCreateGameButton( button );
label = CCLabelTTF::create( "Random Room", "fonts/American Typewriter.ttf", fontSize );
label->setColor( ccc3( 0, 0, 0 ) );
sprite = CCScale9Sprite::create("Images/r1.png", rect, rect );
sprite->setScaleX( 1.6f );
sprite->setScaleY( 0.8f );
button = CCControlButton::create( label, sprite );
button->addTargetWithActionForControlEvents( this, cccontrol_selector( CCLobbyView::joinGameButtonCallback ), CCControlEventTouchUpInside);
button->setPreferredSize( rect.size );
position = center;
position.y -= 136;
position.x += 100;
button->setPosition( position );
this->setRandomGameButton( button );
this->_lobbyViewDataSource = new CCLobbyViewDataSource( this );
fontSize = 16;
length = mySize.width;
size = this->_lobbyViewDataSource->cellSizeForTable( NULL );
size.height *= 3;
CCTableView* table = CCTableView::create( this->_lobbyViewDataSource, size );
table->setContentOffset( CCPointZero );
table->setDirection(kCCScrollViewDirectionVertical);
position = center;
position.x -= size.width * 0.5f;
position.y -= fontSize + ( size.height * 0.17f );
table->setPosition( position );
table->setDelegate( this );
table->setVerticalFillOrder(kCCTableViewFillTopDown);
this->setRoomTable( table );
table->reloadData();
fontSize = 16;
label = CCLabelTTF::create("Running games:", "fonts/American Typewriter.ttf", fontSize,
winSize, kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
position = center;
position.x -= size.width * 0.4f;
position.y += size.height - ( fontSize * 0.5f );
label->setPosition( position );
//label->setAnchorPoint( CCPointZero );
this->setRoomTableLabel( label );
fontSize = 16;
CCLabelTTF* console = CCLabelTTF::create("disconnected", "fonts/American Typewriter.ttf", fontSize,
winSize, kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
console->setColor( ccc3(255, 255, 255) );
console->setContentSize(winSize);
position = center;
position.y += 100;
console->setPosition( position );
this->setConsole( console );
label = CCLabelTTF::create( "localhost:5055", "fonts/American Typewriter.ttf", fontSize );
position.y += fontSize;
label->setPosition( position );
this->setDisplayAddress( label );
// top
fontSize = 24;
length = 19;
size = CCSize( length * fontSize * 0.7f, fontSize * 1.7f );
CCEditBox* edit = CCEditBox::create( size, CCScale9Sprite::create( "extensions/green_edit.png" ) );
edit->setPosition( center );
edit->setFontColor(ccBLACK);
edit->setPlaceHolder("ip:port");
edit->setMaxLength( 19 );
edit->setReturnType(kKeyboardReturnTypeDone);
edit->setDelegate(this);
position.y -= fontSize * 2;
edit->setPosition( position );
this->setEditAddress( edit );
//CCChatRoom* chatroom = CCChatRoom::create(this->getNetwork());
//this->setChatRoom( chatroom );
this->scheduleUpdate();
return true;
}
return false;
}