Java Libgdx为什么我的按钮在鼠标点击时没有响应

Java Libgdx为什么我的按钮在鼠标点击时没有响应,java,button,libgdx,mousepress,Java,Button,Libgdx,Mousepress,为什么来自libgdx的我的TextButton在点击时没有响应 我有一个按钮,这个按钮有一个侦听器,但它没有响应。 按钮正在显示,但在鼠标单击时没有响应 public MyStage extends Stage { ... next.addListener(new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, i

为什么来自libgdx的我的
TextButton
在点击时没有响应

我有一个按钮,这个按钮有一个侦听器,但它没有响应。 按钮正在显示,但在鼠标单击时没有响应

public MyStage extends Stage {
     ...
     next.addListener(new InputListener() {
        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button)
        {
            Gdx.app.log(ApothecaryGame.LOG, "Pressed: Next button.");
            return true;
        }
        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            Gdx.app.log( ApothecaryGame.LOG, "Released: Next button.");
            super.touchUp( event, x, y, pointer, button );
            nextPage();
        }
    } );
    this.addActor(next);
}

将ClickListener添加到按钮。看起来像这样

button.addListener(new ClickListener() {
    public void clicked(InputEvent event, float x, float y) {
        // Do something interesting here...
    }
});
另外,确保将stage设置为输入处理器,否则它将看不到事件

Gdx.input.setInputProcessor(stage);

有人知道为什么吗?确保添加
Gdx.input.setInputProcessor(stage)
进入
公共void show(){}
方法