Input does not work in canvas

hello,



I’ve created a canvas in LWJGL and attached it to a JFrame. Now, my input would not work anymore. Can some one tell me what to do to get it running again.



I found this nice thread here, but I could not get it working. I tried to call the following code in a custom class extending Application in the initialize method after super.initialize()…



// input

mouseInput = new AwtMouseInput(((JmeCanvasContext) getContext()).getCanvas());

if (mouseInput != null)

mouseInput.initialize();



keyInput = new AwtKeyInput(((JmeCanvasContext) getContext()).getCanvas());

if (keyInput != null)

keyInput.initialize();



if (!settings.getBoolean(“DisableJoysticks”)){

joyInput = context.getJoyInput();

if (joyInput != null)

joyInput.initialize();

}



inputManager = new InputManager(mouseInput, keyInput, joyInput);




didn’t help either. what can i do??



thanks in advance,

Fellkneul

Did you look in the TestCanvas example? It shows an example of a canvas inside a swing gui, where by dragging the mouse you can control the 3D camera.

oops, sorry. no, i didn’t. I will have a look at that first and tell you later whether this was helpful.

I am struggling with similar thing. I made my own camera controller, looks like flyCam, only that mine is also implementing RawInputListener. So I am implementing this abstract method:

@Override

public void onMouseMotionEvent(MouseMotionEvent evt)

{

if (!enabled)

return;



System.out.print(“mm”);

mouseX = evt.getX();

mouseY = evt.getY();

}



The problem is that this method is never executed (I never get output “mm” in console). Anyone knows how to make that work?

Did you register the listener?



inputManager.addRawInputListener(this);



Also, you have to implement RawInputListener when you want to listen to raw input… The onMouseMotionEvent() will not be called by it.



If you want to listen to Mouse input, you have to implement MouseInputListener and add the listener and binding to the inputManager:



inputManager.addMapping(“MouseAxisX”, new MouseAxisTrigger(MouseInput.AXIS_X, false));

inputManager.addMapping(“MouseAxisY”, new MouseAxisTrigger(MouseInput.AXIS_Y, false));



inputManager.addListener(this, “MouseAxisX”);

inputManager.addListener(this, “MouseAxisY”);





Cheers,

Normen

normen, every time you solve all my problems in one post lol.

IMO, you pwn jMonkeyEngine. :slight_smile:

BIG THANKS for all your contributions here!

well… i did it. i used to work with my own class extended from application. i tried it with SimpleApplication and modified it to fit my needs step by step and now everything is working. the just must have been some simple kind of mistake i did, some code i left out which can be found in SimpleApplication. however, everything is working now. thanks for help. :slight_smile:



Fellkneul