[Solved]Can not display text on my skin

mos

20-03-2011 10:12:31

Hi,
I create a simple skin by skineditor and export it to layouteditor.

<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Resource" version="1.1">
<Resource type="ResourceSkin" name="mybutton" size="18 17" texture="MyGUI_BlueWhiteSkins.png">
<BasisSkin type="SubSkin" offset="0 0 18 17" align="Stretch">
<State name="normal" offset="71 20 18 17"/>
<State name="highlighted" offset="71 39 18 17"/>
<State name="pushed" offset="71 58 18 17"/>
</BasisSkin>
<BasisSkin type="SimpleText" offset="0 0 17 17" align="Stretch">
<State name="normal" colour="0 0 0" shift="0"/>
<State name="highlighted" colour="0 0 0" shift="0"/>
<State name="pushed" colour="0 0 0" shift="0"/>
</BasisSkin>
</Resource>
</MyGUI>

I used the skin as a button but can not see the caption. I debug into it and find if the button use default skin "button" the simpletext part will call EditText::setFontName, but use the skin "mybutton" never call it, so the mTexture is nullptr and never render.
How to solve it, then?

my.name

21-03-2011 20:15:15

look at skin "ButtonSkin" and template "Button"

mos

22-03-2011 09:55:56

Ok, the skin set by layouteditor may be a skin or a templateļ¼Œ It confused me much.
and finally I find the code:

if (LayoutManager::getInstance().isExist(_skinName))
templateInfo = LayoutManager::getInstance().getByName(_skinName);
else
skinInfo = SkinManager::getInstance().getByName(_skinName);


I have a suggestion that use template name and skin name two names instead of only one.
then if I need a different skin button , just set the template name as 'Button' and change the skin name will be ok,
and simple.

Altren

22-03-2011 11:42:25

Widget can't have both template and skin. Template contain one or several skins in template's child widgets.
Also simple skins like panels, images or some rectangles doesn't require templates. That's why you can use skin or template.

mos

23-03-2011 02:00:39

I got your meaning. Thanks.
And for my original problem, just give the button a fontname (not keep [Default]) then the caption will display.
but this seem's a trick not native, and hope there are some document about it.