keyback wp8 failed

keyback wp8 failed
0.0 0


Hi All!
I was using cocos2dx v2.2.2 and I edit function OnBackKeyPress() in Cocos2dRenderer

bool Cocos2dRenderer::OnBackKeyPress()
    CCDirector* pDirector = CCDirector::sharedDirector();
    return true;

When I call CCLog write debug it worked. but if I create new scene, label… it not work.
I don’t know why? Anyone help me, please

BackButtom wp8-xaml

Oh, i will have a try in this test case. thank you.


It working with project native, but not work with xaml. I don’t know why, it will break when create new label or scene…
can i add your skype?


I’m not use skype, you can send me an email:


thank. if I have any questions, I will send mail for you. :slight_smile:
my email:


Hi, Mai Dung, may be you do the work in the Main Thread, no in the opengl thread. You have to inherit the InputEvent, and throw the event to the thread where cocos2d-x draw the UI. You can do like this:

class BackkeyEvent : public InputEvent
        virtual void execute(Cocos2dRenderer ^ renderer);

void BackkeyEvent::execute( Cocos2dRenderer ^ renderer )

bool Direct3DInterop::OnBackKeyPress()
    std::lock_guard guard(mMutex);
    std::shared_ptr e(new BackkeyEvent());
    return true; // return true here to avoid the mainthread do it again

// user pressed the Back Key on the phone
bool Cocos2dRenderer::OnBackKeyPress()
    CCDirector* pDirector = CCDirector::sharedDirector();

    // return to the main test UI
    CCScene* pScene = CCScene::create();
    CCLayer* pLayer = new TestController();

    return true;


oh, thanks so much :slight_smile:


Hey Guys,

I Overloaded as follows on wp8-xaml and I have no issues?
EDIT: Actually it seems to randomly crash sometimes, I’ll try to resolve this with MS as it doesn’t seem to be cocos2d-x thats causing it its the interop of c++ and c#.

bool Cocos2dRenderer::OnBackKeyPress()
	return true;

This way It will react the exact same way as android when we overload the virtual void keyBackClicked(void) function in our layers :slight_smile:

Don’t forget to add setKeypadEnabled(true); in the init of your layers.
That may have been the cause of your issue?

Kind Regards