views:

587

answers:

1

I have a MIDP application that I would like to run on BlackBerry devices. It's quite generic, the one gotcha is that when I override the Canvas keyPressed(int keyCode) method, I'm not capturing the trackpad click events.

Normally you would use getGameAction(keyCode) == FIRE to capture the center of the navigation pad button on MIDP devices, but in this case no luck. I've done extensive searching of blackberry forums and I can't find any clear solution. Is they keyPressed method even called when the trackball button is clicked? What is the appropriate keyCode?

I know that if I move over the BlackBerry SDK I can use key listeners and trackpad clicked type events, but I would like to first attempt to find a solution that is pure MIDP and does not require multiple builds.

+1  A: 

According to the RIM javadoc for the Canvas class the trackball keycode is -8. That's a JDE 4.5 link, but it's the same in 4.3, 4.6 and 4.7. So you could put in some conditional behaviour for BlackBerry handsets that would look for that code.

I don't have time to verify this right now, so HTH.

martin clayton
awesome thanks. I stared at that doc but missed that part.
sbwoodside