本文整理汇总了C++中CCEditBox::setInputMode方法的典型用法代码示例。如果您正苦于以下问题:C++ CCEditBox::setInputMode方法的具体用法?C++ CCEditBox::setInputMode怎么用?C++ CCEditBox::setInputMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCEditBox
的用法示例。
在下文中一共展示了CCEditBox::setInputMode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool MainMenuBarLayer::init()
{
if ( !CCLayer::init() )
{
return false;
}
CCDirector* pDirector = CCDirector::sharedDirector();
pDirector->getTouchDispatcher()->addTargetedDelegate(this, kCCMenuHandlerPriority, true);
// Display Size
CCSize visibleSize = pDirector->getVisibleSize();
// Background Image for menu bar
CCScale9Sprite* scale9Sprite = CCScale9Sprite::create("frame_v.png");
scale9Sprite->setContentSize(ccp(visibleSize.width,visibleSize.height/10));
scale9Sprite->setPosition(ccp(visibleSize.width/2,visibleSize.height - scale9Sprite->getContentSize().height/2));
this->addChild(scale9Sprite,4);
// Go back to privious scene
CCMenuItemImage* menuBackItem = CCMenuItemImage::create("frame_g.png","frame_p.png",this,menu_selector(MainMenuBarLayer::goBackScene));
menuBackItem->setPosition(ccp(menuBackItem->getContentSize().width/2, visibleSize.height - menuBackItem->getContentSize().height/2));
CCMenu* menuBack = CCMenu::create(menuBackItem, NULL);
menuBack->setPosition(CCPointZero);
//this->addChild(menuBack);
// Send a message
CCMenuItemImage* sendItemImg = CCMenuItemImage::create("frame_g.png","frame_p.png",this,menu_selector(MainMenuBarLayer::goBackScene));
sendItemImg->setPosition(ccp(visibleSize.width - sendItemImg->getContentSize().width/2, visibleSize.height - sendItemImg->getContentSize().height/2));
CCMenu* menuSend = CCMenu::create(sendItemImg, NULL);
menuSend->setPosition(CCPointZero);
//this->addChild(menuSend);
// EditBox
CCEditBox* editBox;
CCSize editBoxSize = CCSizeMake(100, 100);
editBox = CCEditBox::create(editBoxSize, CCScale9Sprite::create("frame_g.png"));
editBox->setPosition(ccp(visibleSize.width - sendItemImg->getContentSize().width/2, visibleSize.height - sendItemImg->getContentSize().height/2));
editBox->setFontColor(ccBLUE);
editBox->setPlaceHolder("");
editBox->setMaxLength(100);
editBox->setFontSize(24);
editBox->setDelegate(this);
editBox->setTag(_EDITBOX_);
editBox->setInputMode(kEditBoxInputModeAny);
//editBox->setReturnType(kKeyboardReturnTypeSend);
this->addChild(editBox,5);
// End
return true;
}
示例2: 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);
}
示例3: 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;
}