1
\$\begingroup\$

i'm having a problem adding ImageButtons to a Table in libGDX. The buttons seem to work fine when i add them directly to the stage, i can click on them, and they change textures and do whatever they are suppossed to. However, when i add them to a table, and then add the table to the stage, i can't click on them for some reason.

This is how i'm creating a button (aButton is an ImageButton which i declared preivously)

public void configAButton(Texture pressedTexture,Texture notPressedTexture) 
{ 
Skin skin = new Skin();
skin.add("button_down", pressedTexture);
skin.add("button_up", notPressedTexture);
ImageButton.ImageButtonStyle buttonStyle = new ImageButton.ImageButtonStyle();
buttonStyle.imageUp = skin.getDrawable("button_up");
buttonStyle.imageDown = skin.getDrawable("button_down");
aButton = new ImageButton(buttonStyle);

}

i use that method in "show()", and once i've done that i create my table like

 userInterfaceTable = new Table();
 userInterfaceTable.setWidth(stage.getWidth());
 userInterfaceTable.align(Align.bottomRight);

i just add the button to the table

userInterfaceTable.add(aButton).size(60,60).padRight(30);

And add the table to the stage

stage.addActor(userInterfaceTable);

what am i missing? thanks in advance, i'm quite new to this.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.