Skip to main content

How to use ActionEvent's getKeyevent() ?

1 reply [Last post]
nafs
Offline
Joined: 2008-06-10
Points: 0

Hello,

I have decoupled my Form and it's ActionListener. That is, my ActionListener is implementd in another class, and not in the Form.

Anyway, I find it really annoying that the keyReleased() method has to be implemented in the Form, and cannot be delegated to the Form's ActionListener (or can I?). Something tells me that I can, because there is ActionEvent has a nice getKeyEvent() method..

Sorry if that sounded confusing, what I basically want is..
=======
public MyForm extends Form

MyActionListener mal = new MyActionListener()
this.setCommandListener(mal);
this.setKeyListener(mal) //There is nothing like this?

So then, in the MyActionListener..

public void actionEvent()
{
if(evt.getCommand() == someCommand)
{
}
if(evt.getKeyEvent() == Display.GAME_RIGHT)
{
}

}

Message was edited by: nafs

Message was edited by: nafs

Message was edited by: nafs

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vprise
Offline
Joined: 2003-11-07
Points: 0

Hi Nafs,
the key in the action event is designed for actionPerformed only and not for navigation events. You can derive the specific element in the form or in order to control elements such as focus you can use other methods.
We are considering the ability of listening to keyPress/release events without deriving form/component but we don't want to increase the size of the API/JAR.

Thanks,
Shai.