Page 1 of 1

assigning a callback to the hold button

PostPosted: Fri Jul 19, 2013 9:58 am
by wallnutmonkeys
Hi, thanks for all the help so far, my app is starting to look like something hehe, quick question, is it possible to specify a callback for the hold button on the phone?

thanks

wallnut

Re: assigning a callback to the hold button

PostPosted: Tue Jul 23, 2013 9:33 am
by sruffell
Yes, you should be able to use onkey to add a handler to the top level window.

For example, if I add to the end of helloworld.js
Code: Select all
window.onkey = function(ev) {
    util.debug("window:" + JSON.stringify(ev));
    return 0;
};


And then run it, I get the following output on the debug log when I press the various keys:
Code: Select all
$ ./update.sh log



+Done loading util.js
app.js:Init
                        app.init:appConfigXML:{"$NAME":"appconfig","$CHILDREN":[]}
                        app.init:this.config:{}
auth.js:Constructor
Could not load app specific language keys for fallback lang: en_us
Could not load app specific language keys for lang: en_us
window:{"key":"hold","type":"key"}
window:{"key":"xfer","type":"key"}
window:{"key":"msgs","type":"key"}


If you return true or 1 from the handler, you can prevent the key from being passed to the phone application if you would like.

Re: assigning a callback to the hold button

PostPosted: Tue Jul 23, 2013 11:34 am
by wallnutmonkeys
thx a lot

wallnut