Question about MouseInputListener

Hi!!!



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){
      if(MouseManager.menuEnable){
         menu.setLocalTranslation(new Vector3f(newX, newY, 0));
         menu.setCullMode(Spatial.CULL_NEVER);
               
         setMenuFocus(newX, newY);
      }
      else{
         menu.setCullMode(Spatial.CULL_ALWAYS);
      }            
   };
});



Now its working....


This is the better way?

Thank you irrisor!!!