Page 1 of 1

getting a child

Posted: Tue Nov 20, 2007 17:46
by rogerdv
I have the following layout:

Code: Select all

Window Type="TaharezLook/FrameWindow" Name="charWindow">
             <Property Name="UnifiedPosition" Value="{{0.3,0},{0.2,0}}" />
             <Property Name="UnifiedSize" Value="{{0.45,0},{0.5,0}}" />
             <Property Name="Visible" Value="false" />
        <Window Type="TaharezLook/TabControl" Name="charInfo">
                <Property Name="UnifiedPosition" Value="{{0.0,0},{0.01,0}}" />
                <Property Name="UnifiedSize" Value="{{1.0,0},{0.8,0}}" />
      <Window Type="TaharezLook/TabContentPane" Name="charAttr">
                   <Property Name="UnifiedPosition" Value="{{0.0,0},{0.01,0}}" />
         <Property Name="UnifiedSize" Value="{{1.0,0},{0.98,0}}" />                  
         <Property Name="Text" Value="Attributes" />
         <Window Type="TaharezLook/StaticText" Name="Strength">
            <Property Name="UnifiedPosition" Value="{{0.03,0},{0.1,0}}" />
            <Property Name="UnifiedSize" Value="{{0.2,0},{0.17,0}}" />                  
            <Property Name="Text" Value="Strength" />
            <Property Name="FrameEnabled" Value="false" />
         </Window>


I need to get the static text named Strength, but I cant find a wa to do it. I have tried several variations of this:

Code: Select all

test = (CEGUI::FrameWindow*)charWin->getChild("charInfo")->getChild("charAttr")->getChild("Rmagic");

but always got an exception saying that cant find it.

Posted: Tue Nov 20, 2007 20:21
by Rackle
I usually create a "directory structure" with my frame windows. Something like:

Code: Select all

/charWindow
/charWindow/charInfo
/charWindow/charInfo/charAttr
/charWindow/charInfo/charAttr/Strength


Then use

Code: Select all

WindowManager->getWindow("/charWindow/charInfo/charAttr/Strength")

or in your case, simply

Code: Select all

WindowManager->getWindow("Strength")


Naturally you have to get the Window Manager's singleton before you can actually use the code above.

One reason for my verbose hierarchy is to ensure that the Cegui:Window names are unique: you cannot have another Cegui:Window with the name "Strength", even if it is in a different FrameWindow.

Posted: Wed Nov 21, 2007 15:14
by rogerdv
Thanks for the tip! I have found another doubt, should I get the static text as a FrameWindow or as DefaultWindow?

Posted: Thu Nov 22, 2007 09:29
by CrazyEddie
The Static type windows should all be accessed as "DefaultWindow"

HTH

CE.