Mouse Button Issue

Im trying to handle events from mouse as described in the tutorials, but im having problems with the mouse buttons. This seems to only affect the mouse buttons, as keyboard and the axis inputs from the mouse are working properly. The buttons however are not generating events for me. Anyone know what might cause this?

// camera mouse button inputs this.app.getInputManager() .addMapping("Select Button", new MouseButtonTrigger(MouseInput.BUTTON_LEFT)); this.app.getInputManager() .addMapping("Action Button", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
    // camera mouse axis inputs
    this.app.getInputManager()
            .addMapping("Camera Rotate Left", new MouseAxisTrigger(MouseInput.AXIS_X, true));
    this.app.getInputManager()
            .addMapping("Camera Rotate Right", new MouseAxisTrigger(MouseInput.AXIS_X, false));      
// Generic Action Key Inputs this.app.getInputManager() .addListener(this, new String[]{"Select Button"}); this.app.getInputManager() .addListener(this, new String[]{"Action Button"});
    // Camera Axis Inputs
    this.app.getInputManager()
            .addListener(this, new String[]{"Camera Rotate Right"});
    this.app.getInputManager()
            .addListener(this, new String[]{"Camera Rotate Left"});

Looks ok to me on quick glance. This part is unnecessary: new String[]{

…but it shouldn’t cause any problems.

Note: also the point of the var-args form is that you don’t have to call addListener 4 times just to add the same listener:
this.app.getInputManager.addListener( this, “Select Button”, “Action Button”, “Camera Rotate Right”, “Camera Rotate Left”);

…how are you determining that they are not triggering? What interfaces does “this” implement? Can we see those methods?

I’ll post the whole class below to show you how im imp’ing the listener. As for testing, im running the program in debug mode while breaking on the first "if (name.equals( " lines under onAnalog and onAction. The program breaks and gives proper names for the keyboard buttons and mouse axises. I disabled the axises bindings to test the mouse buttons. The program never breaks on any of the mouse buttons.

import com.jme3.app.Application;
import com.jme3.app.SimpleApplication;
import com.jme3.app.state.AbstractAppState;
import com.jme3.app.state.AppStateManager;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.AnalogListener;
import com.jme3.math.Vector3f;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.nifty.screen.ScreenController;

public class State_Map3d extends AbstractAppState implements ScreenController,
ActionListener,
AnalogListener
{
private Nifty nifty;
private Screen screen;
private SimpleApplication app;

// Flag for camera rotation button being depressed
private boolean             Camera_RotationToggle = false;

// Reference to the map class
private Map_Main            Map;

public State_Map3d(Map_Main newMap)
{
    // create reference to the map class instance.
    this.Map = newMap;        

    // disable this state by default so it
    // wont except events as soon as its created
    this.setEnabled(false);
    
}

@Override
public void bind(Nifty nifty, Screen screen)
{
this.nifty = nifty;
this.screen = screen;
}

@Override
public void onStartScreen()
{
// set state enabled, so input will be handled.
this.setEnabled(true);

    // Put the make into the correct mode
    this.Map.setDisplayMode(Map_Main.Visible_3d);
    
    
    // make the standard cursor invisible.
    //org.lwjgl.input.Mouse.setGrabbed(true);           
}

@Override
public void onEndScreen()
{
// disable the state, prevents input handling
// by this class.
this.setEnabled(false);
}

@Override
public void initialize(AppStateManager stateManager, Application app)
{
super.initialize(stateManager, app);
this.app=(SimpleApplication)app;

    // assign keys to this class for events
    // the following lines allow this class to 
    // read these key inputs. Actual keys assocatied 
    // with the input names are stored under MenuConfig
    
    // Camera Keys Inputs
    this.app.getInputManager()
            .addListener(this, new String[]{"Camera Left"});
    this.app.getInputManager()
            .addListener(this, new String[]{"Camera Right"});
    this.app.getInputManager()
            .addListener(this, new String[]{"Camera Forward"});
    this.app.getInputManager()
            .addListener(this, new String[]{"Camera Back"});
    
/**
    // Camera Axis Inputs
    this.app.getInputManager()
            .addListener(this, new String[]{"Camera Rotate Right"});
    this.app.getInputManager()
            .addListener(this, new String[]{"Camera Rotate Left"});
    this.app.getInputManager()
            .addListener(this, new String[]{"Camera Rotate Up"});
    this.app.getInputManager()
            .addListener(this, new String[]{"Camera Rotate Down"});                
**/

   
    this.app.getInputManager()
            .addListener(this, new String[]{"Camera Zoom In"});                
    this.app.getInputManager()
            .addListener(this, new String[]{"Camera Zoom Out"});                                
    
    // Camera Actions
    this.app.getInputManager()
            .addListener(this, new String[]{"Camera Rotation Toggle"});
    
    
    // Generic Action Key Inputs
    this.app.getInputManager()
            .addListener(this, new String[]{"Select Button"});
    this.app.getInputManager()
            .addListener(this, new String[]{"Action Button"});                
    this.app.getInputManager()
            .addListener(this, new String[]{"Toggle Map"});
    
    
    
    
}    

@Override
public void onAnalog(String name, float value, float tpf)
{
// block input events on disabled class
if(!this.isEnabled()) { return; }

    if (name.equals("Camera Rotate Left")) 
    {
        if(this.Camera_RotationToggle)
        {    
            this.Map.rotateCamera(value, tpf,
                    app.getCamera().getLeft());
        }    
    } 
    
    if (name.equals("Camera Rotate Right")) 
    {
        if(this.Camera_RotationToggle)
            this.Map.rotateCamera(-value, tpf,
                    app.getCamera().getLeft());
    } 
    
    if (name.equals("Camera Rotate Up")) 
    {
        if(this.Camera_RotationToggle)
            this.Map.rotateCamera(value, tpf,
                    app.getCamera().getUp());
    } 
    
    if (name.equals("Camera Rotate Down")) 
    {
        if(this.Camera_RotationToggle)
            this.Map.rotateCamera(-value, tpf,
                    app.getCamera().getUp());
    } 
    
    
    
}   

@Override
public void onAction(String name, boolean keyPressed, float tpf)
{
// block input events on disabled class
if(!this.isEnabled()) { return; }

    // Flag camera rotation key being held and released
    if (name.equals("Camera Rotation Toggle")) 
    {
        if(keyPressed)
        {
            this.Camera_RotationToggle = true;
        }
        else
        {
            this.Camera_RotationToggle = false;
        }
        
        return;
    }       
    
    if (name.equals("Toggle Map"))
    {
        // change to 2d map view
        nifty.gotoScreen("GUI_Map2d");      
    }
    
   
    
}

@Override
public void update(float tpf)
{

}  

}

If this is a nifty screen then it might be gobbling up the mouse events.

Thank you, that turned out to be the problem. I cut/paste some information in my nifty .xml and the layer was gobbling my button events.