开发者

J2ME handleKeyReleased affecting DefaultCommand

开发者 https://www.devze.com 2023-03-28 14:40 出处:网络
I am having a bit of a problem with an app I\'m developing for BlackBerry. I have a series of Item objects on the screen, each with a DefaultCommand tied to it. Example

I am having a bit of a problem with an app I'm developing for BlackBerry.

I have a series of Item objects on the screen, each with a DefaultCommand tied to it. Example below:

...
cmdBrowse = new Command(temp.id,Command.ITEM,0);        
mainList.setDefaultCommand(cmdBrowse);
mainList.setItemCommandListener(icl);
...

Previously just clicking on the item with the confirm button would run the proper command. No problem there.

Then I added the handleKeyReleased method to capture the BlackBerry's back button as follows:

protected boolean handleKeyReleased(int keyCode, int gameAction) {
if(keyCode==1769472) {
    /*code to deal with back button*/
    return true;
} else {
    return false;
}
}

Now when I click on the mainList Item with the confirm button, it 开发者_开发问答brings up the list of commands first and I have to click again to actually run the command. Two clicks where it used to be one.

So, is there a way to either:

A. Keep the single click behaviour while still being able to capture the back button with handleKeyReleased

or

B. Capture the back button in a different way ?


I ended up overlooking one very simple thing. All I had to do was call the superclass's handleKeyReleased method and everything worked perfectly.

0

精彩评论

暂无评论...
验证码 换一张
取 消