StaticText as child of PushButton

Help and discussion regarding skinning, themes, and other artistic content.

Moderators: CEGUI MVP, CEGUI Team

r0br0y
Not too shy to talk
Not too shy to talk
Posts: 26
Joined: Thu Apr 08, 2010 09:36

StaticText as child of PushButton

Postby r0br0y » Wed May 12, 2010 16:24

Hi,

I'm wondering how to define the look&feel of a button that uses a statictext for it's label (instead of a textcomponent) that should be accessible from code to get/set the statictext-properties.
The reason for that is the need of getting the VertExtent of the buttonlabel to adjust the button's height and setting the HorzFormatting.


Thanks for any advice
rob

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: StaticText as child of PushButton

Postby CrazyEddie » Thu May 13, 2010 09:13

First you remove any existing label ImagerySection and it's associated references in the StateImagery definitions. You then basically add the static text to the button via the <Child> component tag (http://cegui.org.uk/docs/current/fal_el ... _ref_sec_5). That will take care of one portion of the issue.

The second part is to expose the StaticText properties to the owning button, you can do this via the PropertyLinkDefinition element (http://cegui.org.uk/docs/current/fal_el ... ref_sec_27), which can be used to define new properties on the Button which will be linked to properties on some other element (usually a child).

CE

r0br0y
Not too shy to talk
Not too shy to talk
Posts: 26
Joined: Thu Apr 08, 2010 09:36

Re: StaticText as child of PushButton

Postby r0br0y » Wed Jul 07, 2010 09:15

Hi CE,

I'm running into some problems when adding a static-text-child to my button. I think the main issue is related to the nameSuffix in
<Child type="MyLookNFeel/StaticText" nameSuffix="__text">...</Child>
If it doesn't start with "__auto_" the static_text is created as a child that is selectable in the LayoutEditor and is a "real" child-window of my button... Unfortunately the loading of layout fails with "GUILayout_xmlHandler::startElement - layout loading has been aborted since Window named 'Root/Button__text' already exists." which makes somehow sense in that way...

If I add the "__auto_" (as seen in the other .looknfeel-files) the child is not created at all....

My simple-text-button:

Code: Select all

<WidgetLook name="MyLookNFeel/Button">
      <Child type="MyLookNFeel/StaticText" nameSuffix="__auto_text">
        <Area>
          <Dim type="LeftEdge"><AbsoluteDim value="0" /></Dim>
          <Dim type="TopEdge"><AbsoluteDim value="0" /></Dim>
          <Dim type="RightEdge"><UnifiedDim scale="1" offset="0" type="RightEdge" /></Dim>
          <Dim type="BottomEdge"><UnifiedDim scale="1" offset="0" type="BottomEdge" /></Dim>
        </Area>
        <Property name="AlwaysOnTop" value="true" />
        <Property name="BackgroundEnabled" value="false" />
      </Child>
      <StateImagery name="Normal" />
      <StateImagery name="Hover" />
    </WidgetLook>


any ideas?
thanks

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: StaticText as child of PushButton

Postby CrazyEddie » Thu Jul 08, 2010 08:57

What we will call the implicit requirement for those child windows to use the '__auto_' convention is totally wrong. We should use another technique to detect whether a window comes via the looknfeel.

With regards to the window not being created when using an '__auto_' based name, is this in the app code, the CELayoutEditor or both? Very strange. One I know where I can look into this, I will ;)

CE.

r0br0y
Not too shy to talk
Not too shy to talk
Posts: 26
Joined: Thu Apr 08, 2010 09:36

Re: StaticText as child of PushButton

Postby r0br0y » Mon Jul 12, 2010 10:33

It happens both - in the CELayoutEditor and my app...

thanks much, it would be really great to use that!
rob

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: StaticText as child of PushButton

Postby CrazyEddie » Fri Jul 16, 2010 08:34

Thanks for confirming it happens 'always'. I'll test it out and get back to you in a day or two...

CE

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: StaticText as child of PushButton

Postby CrazyEddie » Fri Jul 23, 2010 09:25

CrazyEddie wrote:I'll test it out and get back to you in a day or two...

Or a week :oops:

I did test this, using TaharezLook parts and it seems to work ok for me; I was able to successfully have a TaharezLook/StaticText as a child specified in the looknfeel with name suffix "__auto_static" and it gets created ok.

I can't think of anything that could cause this issue, except if it bails out part way through constructing the object - presumably there are no errors in the log and/or no exceptions being thrown?

CE.

r0br0y
Not too shy to talk
Not too shy to talk
Posts: 26
Joined: Thu Apr 08, 2010 09:36

Re: StaticText as child of PushButton

Postby r0br0y » Thu Aug 19, 2010 14:43

Hi CE,

thanks for the testing - I finally came back on that topic and the statictext gets created fine with its name set to "__auto_static" BUT I can't see/access/edit its text.
I spend some time with the propertylinkdefinition-stuff but gotten nowhere. Am I right, that I have to link the text-property of my __auto_static-widget to my button to use it?
I tried <PropertyLinkDefinition name="Text" widget="__auto_static" initialValue="" layoutOnWrite="true" /> and some more varianties but then I get the "already exist"-error I had before (btw, it was actually not caused by the child-definition) .


So how can I use the text of the staticText-child properly?

Thanks much
rob

r0br0y
Not too shy to talk
Not too shy to talk
Posts: 26
Joined: Thu Apr 08, 2010 09:36

Re: StaticText as child of PushButton

Postby r0br0y » Fri Aug 20, 2010 12:13

I'm getting closer... I finally realized that all my problems where caused by redefining the "Text"-property (of my button) that should link to the "Text"-property of the StaticText-child...

I think I can't replace/overwrite existing properties?


thanks
rob

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: StaticText as child of PushButton

Postby CrazyEddie » Sun Aug 22, 2010 09:54

Yeah you can't replace / shadow an existing property with a PropertyDefinition or PropertyLinkDefinition. You can add a new one though, for example 'Label' or something, you also need to specify the name of the property on the target:

Code: Select all

<PropertyLinkDefinition name="Label" widget="__auto_static" targetProperty="Text" initialValue="" layoutOnWrite="true" />


HTH

CE


Return to “Skins and Themes”

Who is online

Users browsing this forum: No registered users and 12 guests