MouseClick double counting

I have followed the wiki's instructions on the way to implement mouse click handling, however each click seems to be counted twice.

Ok, I have the following code to register a click listener -

buttonAction = new InputAction() {
            public void performAction( InputActionEvent evt ) {
         ih.addAction(buttonAction, InputHandler.DEVICE_MOUSE, 0 , InputHandler.AXIS_NONE, false );

Where 'ih' is the InputHandler registered to the AbsoluteMouse.

In the update method, I have to call ih.update(f) and I think this is where the problem lies.
Within dealWithClick() i have a system.out.println() which prints something, and everytime I click the mouse this message prints twice so I know things are being double counted.

Any ideas what is wrong?

You're probably getting the mouse being pressed and then being released…

You might try adding the following to the beginning of the performAction method to make sure you're getting the mouse only when its down:

if(MouseInput.get().isButtonDown(0)) return;

1 Like