本文整理汇总了C++中CCEditBox类的典型用法代码示例。如果您正苦于以下问题:C++ CCEditBox类的具体用法?C++ CCEditBox怎么用?C++ CCEditBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CCEditBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: openKeyboard
void CCEditBoxImplWin::openKeyboard()
{
if (m_pDelegate != NULL)
{
m_pDelegate->editBoxEditingDidBegin(m_pEditBox);
}
CCEditBox* pEditBox = this->getCCEditBox();
if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler())
{
cocos2d::CCScriptEngineProtocol* pEngine = cocos2d::CCScriptEngineManager::sharedManager()->getScriptEngine();
pEngine->executeEvent(pEditBox->getScriptEditBoxHandler(), "began",pEditBox);
}
std::string placeHolder = m_pLabelPlaceHolder->getString();
if (placeHolder.length() == 0)
placeHolder = "Enter value";
char pText[100]= {0};
std::string text = getText();
if (text.length())
strncpy(pText, text.c_str(), 100);
bool didChange = CWin32InputBox::InputBox("Input", placeHolder.c_str(), pText, 100, false) == IDOK;
if (didChange)
setText(pText);
if (m_pDelegate != NULL) {
if (didChange)
m_pDelegate->editBoxTextChanged(m_pEditBox, getText());
m_pDelegate->editBoxEditingDidEnd(m_pEditBox);
m_pDelegate->editBoxReturn(m_pEditBox);
}
}
示例2: CCEditBox
CCEditBox* CCEditBox::create(const CCSize& size, CCScale9Sprite* pNormal9SpriteBg, CCScale9Sprite* pPressed9SpriteBg/* = NULL*/, CCScale9Sprite* pDisabled9SpriteBg/* = NULL*/)
{
CCEditBox* pRet = new CCEditBox();
if (pRet != NULL && pRet->initWithSizeAndBackgroundSprite(size, pNormal9SpriteBg))
{
if (pPressed9SpriteBg != NULL)
{
pRet->setBackgroundSpriteForState(pPressed9SpriteBg, CCControlStateHighlighted);
}
if (pDisabled9SpriteBg != NULL)
{
pRet->setBackgroundSpriteForState(pDisabled9SpriteBg, CCControlStateDisabled);
}
pRet->autorelease();
}
else
{
CC_SAFE_DELETE(pRet);
}
return pRet;
}
示例3: editBoxEditingDidEnd
void HRootLayer::editBoxEditingDidEnd(CCEditBox* editBox) {
int count = m_pEditBoxList->count();
for (int i = 0; i < count; ++i) {
if (editBox == m_pEditBoxList->objectAtIndex(i)) {
do {
++i;
if (i < count) {
CCEditBox *eb = (CCEditBox *)m_pEditBoxList->objectAtIndex(i);
if (eb->isVisible()) {
HTimerManager::getInstance()->asyncProcess(HInvocation::create(this, hinvocation_selector(HRootLayer::onOpenKeyboard), 0, eb));
break;
}
} else {
//delete by zg
// editBox->closeKeyboard();
break;
}
} while (true);
break;
}
}
// if (editBox == m_pEditUsername) {
// HTimerManager::getInstance()->asyncProcess(HInvocation::create(this, hinvocation_selector(HRootLayer::onOpenKeyboard), 0, m_pEditPassword));
//// m_pEditPassword->openKeyboard();
// }
}
示例4: onVersionChanged
void CCEDEVUpgradeConfigScene::onVersionChanged(CCNode* node, const char* name, CCNodeEvent*)
{
CCEditBox* box = (CCEditBox*) node;
std::string s = box->getText();
CCEUpgradeManager* m = CCEUpgradeManager::sharedUpgradeManager();
UpgradeConfig cfg;
m->getConfig(&cfg);
if(cfg.version.compare(s)!=0) {
cfg.version = s;
m->setConfig(&cfg);
}
}
示例5: eventConnected
void CCLobbyView::eventConnected( cocos2d::CCObject* sender )
{
JString userName = "";
CocosNetworkLogic* network = CocosNetworkLogic::getInstance();
CCEditBox *eb = this->getEditName();
const char* ebtext = eb->getText();
if (strlen(ebtext) != 0) {
userName = ebtext;
network->setUserName(userName);
} else {
userName = network->getUserName();
eb->setText(userName.UTF8Representation().cstr());
}
}
示例6: CCSizeMake
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;
}
示例7: nextEditBox
// find next edit box, or null if none
static CCEditBox* nextEditBox(CCEditBox* box) {
for(std::vector<CCEditBox*>::iterator iter = sActiveEditBoxes->begin(); iter != sActiveEditBoxes->end(); iter++) {
if(*iter == box) {
iter++;
if(iter != sActiveEditBoxes->end()) {
CCEditBox* next = *iter;
if(next->isRunning())
return next;
else
return NULL;
} else {
return NULL;
}
}
}
return NULL;
}
示例8: editBoxCallbackFunc
static void editBoxCallbackFunc(const char* pText, void* ctx)
{
CCEditBoxImplAndroid* thiz = (CCEditBoxImplAndroid*)ctx;
thiz->setText(pText);
if (thiz->getDelegate() != NULL)
{
thiz->getDelegate()->editBoxTextChanged(thiz->getCCEditBox(), thiz->getText());
thiz->getDelegate()->editBoxEditingDidEnd(thiz->getCCEditBox());
thiz->getDelegate()->editBoxReturn(thiz->getCCEditBox());
}
CCEditBox* pEditBox = thiz->getCCEditBox();
if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler())
{
cocos2d::CCScriptEngineProtocol* pEngine = cocos2d::CCScriptEngineManager::sharedManager()->getScriptEngine();
cocos2d::extension::KeyboardReturnType returnType = pEditBox->getReturnType();
int handler = pEditBox->getScriptEditBoxHandler();
pEngine->executeEvent(handler, "changed",pEditBox);
if (returnType == cocos2d::extension::kKeyboardReturnTypeDone)
{
pEngine->executeEvent(handler, "returnDone", pEditBox);
}
else if (returnType == cocos2d::extension::kKeyboardReturnTypeSend)
{
pEngine->executeEvent(handler, "returnSend", pEditBox);
}
else if (returnType == cocos2d::extension::kKeyboardReturnTypeSearch)
{
pEngine->executeEvent(handler, "returnSearch", pEditBox);
}
else if (returnType == cocos2d::extension::kKeyboardReturnTypeGo)
{
pEngine->executeEvent(handler, "returnGo", pEditBox);
}
else
{
pEngine->executeEvent(handler, "return", pEditBox);
}
pEngine->executeEvent(handler, "ended",pEditBox);
}
}
示例9: ccpMult
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;
}
示例10: openKeyboard
void CCEditBoxImplWin::openKeyboard()
{
if (m_pDelegate != NULL)
{
m_pDelegate->editBoxEditingDidBegin(m_pEditBox);
}
CCEditBox* pEditBox = this->getCCEditBox();
if (NULL != pEditBox)
{
pEditBox->raiseEvent(NODE_EVENT_EDITBOX_BEGAN,NULL);
}
std::string placeHolder = m_pLabelPlaceHolder->getString();
if (placeHolder.length() == 0)
placeHolder = "Enter value";
char pText[100]= {0};
std::string text = getText();
if (text.length())
strncpy(pText, text.c_str(), 100);
bool didChange = CWin32InputBox::InputBox("Input", placeHolder.c_str(), pText, 100, false) == IDOK;
if (didChange)
setText(pText);
if (m_pDelegate != NULL) {
if (didChange)
m_pDelegate->editBoxTextChanged(m_pEditBox, getText());
m_pDelegate->editBoxEditingDidEnd(m_pEditBox);
m_pDelegate->editBoxReturn(m_pEditBox);
}
if (NULL != pEditBox)
{
if(didChange) {
pEditBox->raiseEvent(NODE_EVENT_EDITBOX_CHANGED, NULL);
}
pEditBox->raiseEvent(NODE_EVENT_EDITBOX_ENDED, NULL);
pEditBox->raiseEvent(NODE_EVENT_EDITBOX_RETURN, NULL);
}
}
示例11: editBoxCallbackFunc
static void editBoxCallbackFunc(const char* pText, void* ctx)
{
CCEditBoxImplTizen* thiz = (CCEditBoxImplTizen*)ctx;
thiz->setText(pText);
if (thiz->getDelegate() != NULL)
{
thiz->getDelegate()->editBoxTextChanged(thiz->getCCEditBox(), thiz->getText());
thiz->getDelegate()->editBoxEditingDidEnd(thiz->getCCEditBox());
thiz->getDelegate()->editBoxReturn(thiz->getCCEditBox());
}
CCEditBox* pEditBox = thiz->getCCEditBox();
if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler())
{
cocos2d::CCScriptEngineProtocol* pEngine = cocos2d::CCScriptEngineManager::sharedManager()->getScriptEngine();
pEngine->executeEvent(pEditBox->getScriptEditBoxHandler(), "changed",pEditBox);
pEngine->executeEvent(pEditBox->getScriptEditBoxHandler(), "ended",pEditBox);
pEngine->executeEvent(pEditBox->getScriptEditBoxHandler(), "return",pEditBox);
}
}
示例12: openKeyboard
void CCEditBoxImplAndroid::openKeyboard()
{
if (m_pDelegate != NULL)
{
m_pDelegate->editBoxEditingDidBegin(m_pEditBox);
}
CCEditBox* pEditBox = this->getCCEditBox();
if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler())
{
cocos2d::CCScriptEngineProtocol* pEngine = cocos2d::CCScriptEngineManager::sharedManager()->getScriptEngine();
pEngine->executeEvent(pEditBox->getScriptEditBoxHandler(), "began",pEditBox);
}
showEditTextDialogJNI( m_strPlaceHolder.c_str(),
m_strText.c_str(),
m_eEditBoxInputMode,
m_eEditBoxInputFlag,
m_eKeyboardReturnType,
m_nMaxLength,
editBoxCallbackFunc,
(void*)this );
}
示例13: CCSizeMake
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;
}
示例14: ccpMult
//.........这里部分代码省略.........
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;
}
示例15: openKeyboard
void CCEditBoxImplTizen::openKeyboard()
{
if (m_pDelegate != NULL)
{
m_pDelegate->editBoxEditingDidBegin(m_pEditBox);
}
CCEditBox* pEditBox = this->getCCEditBox();
if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler())
{
cocos2d::CCScriptEngineProtocol* pEngine = cocos2d::CCScriptEngineManager::sharedManager()->getScriptEngine();
pEngine->executeEvent(pEditBox->getScriptEditBoxHandler(), "began",pEditBox);
}
KeypadStyle keypadStyle = KEYPAD_STYLE_NORMAL;
KeypadInputModeCategory keypadCategory = KEYPAD_MODE_ALPHA;
bool bSingleLineEnabled = false;
switch (m_eEditBoxInputMode)
{
case kEditBoxInputModeAny:
keypadStyle = KEYPAD_STYLE_NORMAL;
break;
case kEditBoxInputModeEmailAddr:
keypadStyle = KEYPAD_STYLE_EMAIL;
break;
case kEditBoxInputModeNumeric:
case kEditBoxInputModeDecimal:
keypadStyle = KEYPAD_STYLE_NUMBER;
keypadCategory = KEYPAD_MODE_NUMERIC;
break;
case kEditBoxInputModePhoneNumber:
keypadStyle = KEYPAD_STYLE_PHONE_NUMBER;
break;
case kEditBoxInputModeUrl:
keypadStyle = KEYPAD_STYLE_URL;
break;
case kEditBoxInputModeSingleLine:
bSingleLineEnabled = true;
break;
default:
keypadStyle = KEYPAD_STYLE_NORMAL;
break;
}
bool bTextPrediction = true;
switch (m_eEditBoxInputFlag)
{
case kEditBoxInputFlagPassword:
keypadStyle = KEYPAD_STYLE_PASSWORD;
break;
case kEditBoxInputFlagSensitive:
bTextPrediction = false;
break;
default:
break;
}
((CCOspForm *)CCOspApplication::GetInstance()->getCCOspForm())->ShowKeypad(
m_strText.c_str(),
keypadStyle,
keypadCategory,
bSingleLineEnabled,
bTextPrediction,
m_nMaxLength,
editBoxCallbackFunc,
(void*)this);
}