Question about MouseInputListener


I have a class: MouseManager that extends MouseInputAction and I create a class: JMEMenu. In my class MouseManager, when I press the RMB on enemy shows a menu. What I want is: When I show the menu I want create a "focus"

Well, as you trigger the menu from somewhere (from MouseManager?) you can pass the position with the invocation, can't you?

If you only want to query the current hardware cursor position you can do this with MouseInput.get().get…().

Alternatively you can of course create an additional listener that tracks the mouse position for the menu separately. But I't recommend to have a single piece of code in your application that decides about the mouse position (as you might want to change mouse behaviour at some time).

Hi irrisor!!!

Something like this:

In the class JMEMenu…

MouseInput.get().addListener(new MouseInputListener(){
   public void onButton(int button, boolean pressed, int x, int y){};
   public void onWheel(int wheelDelta, int x, int y){};
   public void onMove(int xDelta, int yDelta, int newX, int newY){
         menu.setLocalTranslation(new Vector3f(newX, newY, 0));
         setMenuFocus(newX, newY);

Now its working....

This is the better way?

Thank you irrisor!!!