ScriptingCore::exeuteLayerKeypadEvent

Hi,

I’ve been using the JS Bindings since it was introduced into cococs2d-2.x. And I’d like to thank all people involved in developing this framework. It’s awesome to use across different platforms.

Ok enough of the praise :slight_smile:

The Back & Home keys are not implented for layers in ScriptingCore the function simply returns 0.

So I’ve implemented it and it seems to work properly on our Android test devices. The code snippet to replace with:

int ScriptingCore::executeLayerKeypadEvent(CCLayer* pLayer, int eventType)
{
    jsval retVal, jsValArr = JSVAL_ZERO;

    js_proxy_t * p;
    JS_GET_PROXY(p, pLayer);
    if (!p) return false;

    switch(eventType)
    {
        case kTypeBackClicked:
        {
            executeJSFunctionWithName(this->cx_, p->obj, "onKeyBackClicked", jsValArr, retVal);
        }
        break;

        case kTypeMenuClicked:
        {
            executeJSFunctionWithName(this->cx_, p->obj, "onKeyHomeClicked", jsValArr, retVal);
        }
        break;
    }
    return 1;
}

I used the “on” prefix to reflect how it’s used in the cocos2d-html5 branch. If someone would be kind enough to make a patch so that this makes it into the git repos that would be awesome.

Thanks again for a great framework!

Thanks for your patch, it looks great. :slight_smile: