keyReleased not working in eclipse
in
Integration and Hardware
•
2 months ago
Hello all :)
I am trying to run my program (simple Cellular automata) under Eclipse environment using Processing 2.x.
Everything works fine, but i cannot capture any keyXXX event or mouseXXX event after staring my app. The same code plced in Processing pde editor runs corractly and captures and handles key events properly.
Has anyone of you spotted simmilar problem?
Here my code for starint PApplet sketch:
- public class Main {
- private static final String DEFAULT_SIZE = "20";
- public static void main(String[] args) {
- if (args.length != 1) {
- PApplet.main(new String[] { CellularAutomataEngine.class.getName(),
- DEFAULT_SIZE, "--present" });
- } else {
- try {
- int size = Integer.parseInt(args[0]);
- if (size < 10 || size > 20) {
- throw new NumberFormatException();
- }
- } catch (NumberFormatException e) {
- System.err
- .println("argument should be integer in range[10, 20]");
- return;
- }
- PApplet.main(CellularAutomataEngine.class.getName(), new String[] {
- args[0], "--present" });
- }
- }
- }
- public class CellularAutomataEngine extends PApplet {
- private static final long serialVersionUID = 1L;
- private CellSpace world = null;
- public CellularAutomataEngine() {
- }
- @Override
- public void setup() {
- super.setup();
- size(300, 300);
- frameRate(10.0f);
- System.out.println("Setup args: " + Arrays.toString(args));
- System.out.println("Setup args[0]: " + args[0]);
- world = new CellSpace(this, Integer.parseInt(args[0]));
- world.randomize();
- }
- @Override
- public void draw() {
- super.draw();
- update(0);
- draw(0);
- }
- @Override
- public void keyPressed() {
- super.keyPressed();
- System.out.println("KeyPressed: '" + key + "'");
- }
- @Override
- public void keyReleased(KeyEvent event) {
- super.keyReleased(event);
- System.out.println("KeyReleasedEvent: '" + event + "'");
- }
- @Override
- public void keyReleased() {
- super.keyReleased();
- System.out.println("KeyReleased: '" + key + "'");
- if (key == ' ' || key == 'r') {
- reset();
- }
- }
- /* rest o code */
- }
The problem is that none of those keyXXX methods are triggered when keyboard is pressed ;(
1