CCLayer::keyBackClicked seems to be binded, but doesn't work

According to ScriptingCore.cpp(ScriptingCore::executeLayerKeypadEvent), it means keyBackClicked has been binded, right?

But when My Layer in js use backClicked(), it doesn’t work. Who can tell me how to use it?

MainScene.prototype.backClicked = function (){
cc.log(“back Clicked”);
};

ps:
logs
07-02 11:38:08.910: W/KeyCharacterMap(7203): Can’t open keycharmap file
07-02 11:38:08.910: W/KeyCharacterMap(7203): Error loading keycharmap file ‘/system/usr/keychars/atmel-touchscreen.kcm.bin’. hw.keyboards.65537.devname=‘atmel-touchscreen’
07-02 11:38:08.960: I/KeyCharacterMap(7203): Using default keymap: /system/usr/keychars/qwerty.kcm.bin

Orca chen wrote:

According to ScriptingCore.cpp(ScriptingCore::executeLayerKeypadEvent), it means keyBackClicked has been binded, right?
>
But when My Layer in js use backClicked(), it doesn’t work. Who can tell me how to use it?
>
MainScene.prototype.backClicked = function (){
cc.log(“back Clicked”);
};
>
ps:
logs
07-02 11:38:08.910: W/KeyCharacterMap(7203): Can’t open keycharmap file
07-02 11:38:08.910: W/KeyCharacterMap(7203): Error loading keycharmap file ‘/system/usr/keychars/atmel-touchscreen.kcm.bin’. hw.keyboards.65537.devname=‘atmel-touchscreen’
07-02 11:38:08.960: I/KeyCharacterMap(7203): Using default keymap: /system/usr/keychars/qwerty.kcm.bin

oh, I found solution.
In layer’s init()this.setKeypadEnabled(true);
then overload this.backClicked()

Hey Orca chen,
Your solution is great and finally I managed that backButton works on Android :slight_smile: Thank you!
But I have one problem. On iOS platform there is no function this.rootNode.setKeypadEnabled(true); but on Android it is.
I tried to check it with sys.capabilities but both on iOS and Android there are only touches, accelerometer and opengl capabilities. I assumed that on Android will be also ‘keyboard’ capability but there isn’t.
So how you check on which platform do you run your app to execute this.setKeypadEnabled(true) or not?

EDIT2: My code that works:

if( sys.os == "android" || sys.os == "Android") {
      this.rootNode.setKeypadEnabled(true);
}

Best regards!

EDIT. One more question. How do you terminate your app when you press back button in main menu?
EDIT3: Next code that seems to work (kills an app):

cc.Director.getInstance().end();

Could you check is this a good way to manage that features?

Tobias S wrote:

Hey Orca chen,
Your solution is great and finally I managed that backButton works on Android :slight_smile: Thank you!
But I have one problem. On iOS platform there is no function this.rootNode.setKeypadEnabled(true); but on Android it is.
I tried to check it with sys.capabilities but both on iOS and Android there are only touches, accelerometer and opengl capabilities. I assumed that on Android will be also ‘keyboard’ capability but there isn’t.
So how you check on which platform do you run your app to execute this.setKeypadEnabled(true) or not?
>
EDIT2: My code that works:
[…]
>
Best regards!
>
EDIT. One more question. How do you terminate your app when you press back button in main menu?
EDIT3: Next code that seems to work (kills an app):
[…]
>
Could you check is this a good way to manage that features?
yep. It works well.

Thanks a lot and I can get key response about “backClicked”, and I want to know if I can get reponse of “menuClicked”?

I tried with same event overrite a “menuClicked” function and it did not run.

zhenyi zhang wrote:

Thanks a lot and I can get key response about “backClicked”, and I want to know if I can get reponse of “menuClicked”?
>
I tried with same event overrite a “menuClicked” function and it did not run.

Hi. I’m not sure, but maybe according to jsb_cocos2dx_auto_api.js (line 6762 in version 2.1.3) it should be “keyMenuClicked”.