MouseInput doesn't recognize my Right Mouse Button

I am trying to write my own InputHandler and I have encountered a strange problem. Take a look at the following test code:


   @Override
   public void performAction(InputActionEvent evt) {
      ArrayList<Integer> pressed = new ArrayList<Integer>();
      for (int i = 0; i < MouseInput.get().getButtonCount(); i++) {
         if (MouseInput.get().isButtonDown(i)) {
            pressed.add(i);
         }
      }
      System.out.println(pressed);
...



When I have pressed my left mouse button, the output is [ 0] (without the space)
When I have pressed my middle mouse button, the output is [2]
BUT when I have pressed my right mouse button, the output is []

- Why shouldn't it recognize it my right mouse button? (I tried trying with INPUT_AWT, but I didn't get any mouse events with it - don't know if I used it correctly, but that's another topic)

- Is it guaranteed that 0, 1(?) and 2 always stand for, respectively, left, right and middle button? If not, how can I find out which constants I should use?

Thank you :)

did you tried this syntax also?



InputAction createAction = new InputAction() {
   @Override
   public void performAction(InputActionEvent evt) {
      if (evt == null || evt.getTriggerPressed()) {
         shootBullet();
      }            
   }
};
inputhandler.addAction( createAction, InputHandler.DEVICE_MOUSE, 1, InputHandler.AXIS_NONE, false );



ahh,

I tried your code, but the shootBullet() line is never executed…



I add my InputAction with InputHandler#addAction(MouseInputAction) and it works fine for my left and middle mouse buttons.

Oh, silly me :roll:



I had a self-written program running that installs a global mouse hook. The program consumes all right mouse clicks because they might start a mouse gesture… If it isn't a mouse gesture, the program performs the click later on, but I guess OGL doesn't notice that.



Well… just forget it :wink:

:slight_smile: