user2303325
user2303325

Reputation: 786

Disabling a TextButton

I am trying to disable a TextButton that I've coded as follows:

    // Setup new game button
    final TextButton newGameButton = new TextButton("New Game", style);
    newGameButton.addListener(new InputListener() {
        @Override
        public boolean touchDown(InputEvent event, float x, float y,
                int pointer, int button) {
            Tyr.getInstance().setScreen(new GameScreen());
            AudioHelper.stopMusic();
            return true;
        }
    });
    table.add(newGameButton).spaceBottom(BUTTON_SPACE);
    table.row();

However, the "setDisabled(true)" function doesn't seem to be working. Is there some other way that I can accomplish this task?

Upvotes: 9

Views: 3255

Answers (1)

user2303325
user2303325

Reputation: 786

Found a solution: "newGameButton.setTouchable(Touchable.disabled);"

Upvotes: 25

Related Questions