Is there a way to put the following code into a json skin file?
private TextButton createMainMenuButton(String name, ClickListener listener){
TextButton button = new TextButton(name, skin, "MainMenuStyle");
button.addListener(listener);
//How to put the following two lines into a JSON skin file?
button.getLabel().setAlignment(Align.left);
button.getLabelCell().pad(5,20,5,20);
return button;
}
Here's my actual json skin sheet:
"com.badlogic.gdx.scenes.scene2d.ui.TextButton$TextButtonStyle": {
"default" : { "font" : "arial_narrow_w_32", "up" : "button" },
"MainMenuStyle" : { "font" : "arial_narrow_w_32", "over" : "overBgMainMenu"}
}
I've tried various things, because I know that TextButton contains a datafield label and therefore I thougth I probably could create somehow a json Label template, which I enter into the TextButton, but unfortunatelly that's not working...
"com.badlogic.gdx.scenes.scene2d.ui.TextButton": {
"MainMenu" : { "style" : "MainMenuStyle", "label" : "MainMenuLabel"}
},
"com.badlogic.gdx.scenes.scene2d.ui.TextButton$TextButtonStyle": {
"default" : { "font" : "arial_narrow_w_32", "up" : "button" },
"MainMenuStyle" : { "font" : "arial_narrow_w_32", "over" : "overBgMainMenu"}
},
"com.badlogic.gdx.scenes.scene2d.ui.Label": {
"MainMenuLabel" : {"style" : "MainMenuLabelStyle", "lineAlign" : "left", "cellDefaults" : "MainMenuLabelCell"}
},
"com.badlogic.gdx.scenes.scene2d.ui.Cell": {
"MainMenuLabelCell" : {"padTop" : 5, "padBottom" : 5, "padLeft": 20, "padRight" : 20}
}
Thanks in advance!
I hope to explain well, plus I think you discuss something in another question, well, my English is not very good and what not this is exactly the result you want, but hopefully this will serve the NEXT class extends Button, and TEXTBUTTON class has variable label pirivate end, why not override the methods that are involved this is a simple example that just have not implemented the capture exceptions ect, this is just an example.
}
for use this example, in your class:
in your .json:
},
.
boolean alignLabelJson for used to activate, alignment from json, use true.
boolean padLabelJson for used to activate, pading from json, use true.