I am developing an application that requires me to override keypressed and released methods in lwuit so as to map specific functons into gamekeys.
The gamekeys work fine when I do this but I'm having trouble adding more than two commands to application. Normally actionlistener would automatically handle the mapping of multiple commands but it does not.
Is it possible to map more than one command to a softkey (like with keycode -7) and have an if statement to dynamically check which command is pressed.
public void keyReleased(int keyCode) {
switch (keyCode) {
case -6: // left cmd key
function a();
return;
case -7: // right cmd key
//Need this to handle more than one command function
return;
}
//function to handle gamekeys
}
Hope I am clear enough with my issue. Please help
In my opinion what you wanna do is not possible. There are always a cancel command in a softkey and the menu (if there are more than one command added) in the other softkey.
To get the correct
keyCode
, to set another funtionallity to the softkey you should get the correctkeyCode
. Make aSystem.out.println("keycode " + keyCode);
before the first line in the method keyReleased