Open hgokturk opened 8 years ago
@hgokturk What's the version of your cocos2d-x?
Could I reproduce this issue 100%?
It happens both for 3.8 & 3.10. I'm sure it is reproducable. I can share editbox initialization codes and my appdelegate or anything else if needed.
@hgokturk please show me the code...
AppDelegate.h
void AppDelegate::applicationDidEnterBackground() {
Director::getInstance()->stopAnimation();
}
void AppDelegate::applicationWillEnterForeground() {
Director::getInstance()->startAnimation();
}
LoginRegisterScene.h
#pragma once
#include "cocos2d.h"
#include "ui/CocosGUI.h"
#include "extensions/cocos-ext.h"
class LoginRegisterScene : public cocos2d::Layer, public cocos2d::extension::EditBoxDelegate
{
public:
static cocos2d::Scene* createScene();
virtual bool init();
CREATE_FUNC(LoginRegisterScene);
void Login(cocos2d::Ref *sender);
virtual void editBoxEditingDidBegin(cocos2d::ui::EditBox* editBox);
virtual void editBoxEditingDidEnd(cocos2d::ui::EditBox* editBox);
virtual void editBoxTextChanged(cocos2d::ui::EditBox* editBox, const std::string& text);
virtual void editBoxReturn(cocos2d::ui::EditBox* editBox);
private:
...............................
cocos2d::ui::EditBox* username;
cocos2d::ui::EditBox* email;
cocos2d::ui::EditBox* password;
...............................
};
Sample init in LoginRegisterScene.cpp
this->username = ui::EditBox::create(Size(320 / Director::getInstance()->getContentScaleFactor(), 70 / Director::getInstance()->getContentScaleFactor()), ui::Scale9Sprite::create(pNormalSprite));
//this->username->setPosition(Vec2(visibleSize.width * 66 / 100 + origin.x, visibleSize.height * 63 / 100 + origin.y));
this->username->setPosition(Vec2(bgSprite->getContentSize().width * 66 / 100, bgSprite->getContentSize().height * 63 / 100));
this->username->setFontName("AmericanTypewriter");
this->username->setFontSize(13);
this->username->setFontColor(Color3B::BLACK);
//username->setPlaceHolder("Kullanıcı Adı:");
this->username->setPlaceholderFontColor(Color3B::WHITE);
this->username->setInputFlag(ui::EditBox::InputFlag::INITIAL_CAPS_WORD);
this->username->setInputMode(ui::EditBox::InputMode::SINGLE_LINE);
this->username->setMaxLength(15);
this->username->setReturnType(ui::EditBox::KeyboardReturnType::DONE);
this->username->setDelegate(this);
this->username->setTag(50);
bgSprite->addChild(this->username, 5);
And the listeners in LoginRegisterScene.cpp
void LoginRegisterScene::editBoxEditingDidBegin(ui::EditBox* editBox)
{
log("editBox %p DidBegin !", editBox);
}
void LoginRegisterScene::editBoxEditingDidEnd(ui::EditBox* editBox)
{
log("editBox %p DidEnd !", editBox);
}
void LoginRegisterScene::editBoxTextChanged(ui::EditBox* editBox, const std::string& text)
{
switch(editBox->getTag()){
case 50:
this->txtUsername = text.c_str();
log("username: %s", this->txtUsername.c_str());
break;
case 100:
this->txtPassword = text.c_str();
log("password: %s", this->txtPassword.c_str());
break;
case 150:
this->txtEmail = text.c_str();
log("email: %s", this->txtEmail.c_str());
break;
}
}
void LoginRegisterScene::editBoxReturn(ui::EditBox* editBox)
{
log("editBox %p was returned !",editBox);
}
I wonder if it's about using #parma once instead #ifndef
@hgokturk Could you make a minimal demo project and send it to me? Thanks.
any fix for this found, it seems like, I am also facing the same issue. but for me it happens in iOS as well. in v3.9
@pabitrapadhy Could I reproduce this issue with cpp-tests? thanks
I realized that after going to background in Android and coming back to foreground, EditBox doesn't show any characters previously entered but keeps them somehow. And it is not touchable.