Simon Woodside
Simon Woodside

Reputation: 7314

Using MIDP Canvas keyPressed / keyCode on BlackBerry to get Canvas.FIRE for trackball click

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.

Upvotes: 2

Views: 1901

Answers (1)

martin clayton
martin clayton

Reputation: 78145

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.

Upvotes: 2

Related Questions