Page 1 of 1

StaticText as child of PushButton

Posted: Wed May 12, 2010 16:24
by r0br0y
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

Re: StaticText as child of PushButton

Posted: Thu May 13, 2010 09:13
by CrazyEddie
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

Re: StaticText as child of PushButton

Posted: Wed Jul 07, 2010 09:15
by r0br0y
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

Re: StaticText as child of PushButton

Posted: Thu Jul 08, 2010 08:57
by CrazyEddie
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.

Re: StaticText as child of PushButton

Posted: Mon Jul 12, 2010 10:33
by r0br0y
It happens both - in the CELayoutEditor and my app...

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

Re: StaticText as child of PushButton

Posted: Fri Jul 16, 2010 08:34
by CrazyEddie
Thanks for confirming it happens 'always'. I'll test it out and get back to you in a day or two...

CE

Re: StaticText as child of PushButton

Posted: Fri Jul 23, 2010 09:25
by CrazyEddie
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.

Re: StaticText as child of PushButton

Posted: Thu Aug 19, 2010 14:43
by r0br0y
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

Re: StaticText as child of PushButton

Posted: Fri Aug 20, 2010 12:13
by r0br0y
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

Re: StaticText as child of PushButton

Posted: Sun Aug 22, 2010 09:54
by CrazyEddie
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