Skip to main content

ActionEvent not consumed.

1 reply [Last post]
ghady_rayess
Offline
Joined: 2009-01-09

Hello,

I'm not sure how event handling is done, but i think the consume() method in ActionEvent is not working properly. Consider the example below: A button is in a form, and both are listening to the FIRE key. Although i "consume" the event in the button's action listener, the Form's action Listener still gets fired!

Any ideas?


public void startApp() {
Display.init(this);
Form form = new Form();
Button b = new Button("Click me");
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
arg0.consume();
Dialog.show("Title", "Button Clicked", "ok", null);
}
});
form.addComponent(b);
form.addGameKeyListener(GameCanvas.FIRE,new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
Dialog.show("Title", "Form Fire Clicked", "ok", null);
}
});
form.setScrollable(false);
form.show();
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ghady_rayess
Offline
Joined: 2009-01-09

Please disregard this post. Guess you have to check whether the event was consumed at the beginning of every actionListener's actionPerformed method.