Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Posts: 140
Registered: ‎02-05-2009
My Device: 8900
Accepted Solution

(blackberry.system.event.KEY_BACK, handleBack): Issue in BB5.0

[ Edited ]

Hi All,


Plz have a look on my code. This code ias being used for adding menuitem in Blackberry 5.0


try {
    blackberry.system.event.onHardwareKey(blackberry.system.event.KEY_BACK, handleBack);
    function handleBack() {
        alert("handle back button");
    if (blackberry.ui.menu.getMenuItems().length > 0) {
        var item = new blackberry.ui.menu.MenuItem(false, 1, "Exit", OnClickExitButton);
} catch (e) {
    alert('exception (addMenus): ' + e.name + '; ' + e.toString());


I am compiling my code in WW SDK 2.3 . while running application in BB 5.0 it gives "refrence error: handleBack is not defined,."

Even feature is added in config file:

  <feature id="blackberry.system" required="true" version=""/>
  <feature id="blackberry.system.event" required="true" version=""/>
  <feature id="blackberry.ui.dialog" required="true" version=""/>


Please let me know the solution. I am stuck here, not able to add menuitem in my application.

Posts: 268
Registered: ‎08-19-2009
My Device: Bold 9700

Re: (blackberry.system.event.KEY_BACK, handleBack): Issue in BB5.0

Define function handleBack() outside of your try block, and outside of whatever function the try block is in.