getting a child

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

User avatar
rogerdv
Quite a regular
Quite a regular
Posts: 62
Joined: Thu Mar 31, 2005 23:21
Contact:

getting a child

Postby rogerdv » Tue Nov 20, 2007 17:46

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.

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Tue Nov 20, 2007 20:21

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.

User avatar
rogerdv
Quite a regular
Quite a regular
Posts: 62
Joined: Thu Mar 31, 2005 23:21
Contact:

Postby rogerdv » Wed Nov 21, 2007 15:14

Thanks for the tip! I have found another doubt, should I get the static text as a FrameWindow or as DefaultWindow?

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

Postby CrazyEddie » Thu Nov 22, 2007 09:29

The Static type windows should all be accessed as "DefaultWindow"

HTH

CE.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 36 guests