the override keyBackClicked() doesn't work for some layers...

Hi,

I want to use back button to close my game or return to the main menu.

After a google, I found I need to override “void MainMenuLayer::keyBackClicked()” on my layers.

I did successful close my game at IntroLayer(loading screen), but after ran into main menu, the back button just not works.

When I check the log, I found this below when I touch the back button on main menu.

11-08 06:43:48.164: I/KeyCharacterMap(27568): Using default keymap: /system/usr/keychars/qwerty.kcm.bin

How can I fix this ?

Thank you.

Sorry…It’s my fault.

I forget to call this->setIsKeypadEnabled(true) when the layer is init().

Thank you.

When I saw the first post in bed via mobile phone, I think you probably forgot to enable it.
After I brushed my teeth and had breakfast, now I’m in front of computer to reply your question, then see your 2nd post. aha :stuck_out_tongue:

Ha…Cool…

But I still have some problems about keyBackClicked().

It seems the layer doesn’t swallow the key event.

Is it true ?

What I mean is if I have two layers that layer2 is on top of layer1.

When I press the back key, both these two layers will get keyBackClicked() called.

Am I right ?

Yeah. You can modify cocos2dx/keypad_dispatcher/CCKeypadDispatcher.cpp

bool CCKeypadDispatcher::dispatchKeypadMSG(ccKeypadMSGType);

to stop this loop

OK…Thanks…