Skip to main content

ActionEvent at List: touching or pressing?

3 replies [Last post]
dtondo
Offline
Joined: 2008-06-14

Hi peaple, i need some help with events
how to know if i'm pressing the fire button or touching on screen?

i'm need to do something when i press firebutton and do nothing when i touch some list item at screen

I tried using this conditional code, but evt.getKeyEvent() always return "-1"

genericList.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (evt.getKeyEvent()==com.sun.lwuit.Display.GAME_FIRE){
//do something
}
}
});

here we can find a similar discussion, but touchscreen was not mentioned:

http://forums.java.net/jive/thread.jspa?messageID=297818&#297818

thanks

Message was edited by: dtondo

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Shai Almog

Hi,
ActionListener is mostly targeted at generic code and doesn't have
this information at this stage.
You should override the keyRelease/pointerRelease methods instead.

> Hi peaple, i need some help with events
> how to know if i'm pressing the fire button or touching on screen?
>
> i'm need to do something when i press firebutton and do nothing
> when i touch some list item at screen
>
> I tried using this conditional code, but evt.getKeyEvent() always
> return "-1"
>
> genericList.addActionListener(new ActionListener() {
> public void actionPerformed(ActionEvent evt) {
> if (evt.getKeyEvent()
> ==com.sun.lwuit.Display.GAME_FIRE){
> //do something
> }
> }
> });
>
> thanks
> [Message sent by forum member 'dtondo' (dtondo)]
>
> http://forums.java.net/jive/thread.jspa?messageID=327704
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]

dtondo
Offline
Joined: 2008-06-14

Hummmmmm

like i thinked

thanks Shai i will try this solution

dtondo
Offline
Joined: 2008-06-14

The solution works properly, i will post the piece of code to help someone who needs it

public void keyPressed(int keyCode){
int keyPressed = Display.getInstance().getGameAction(keyCode);
if (keyPressed == Display.GAME_FIRE){
}else{
// when the key pressed is not "enter/firekey" the form will take control of keyPressed method.
super.keyPressed(keyCode);
}
}

how can i format this texts?

Message was edited by: dtondo