Thread Tools Display Modes
12-03-22, 08:10 AM   #1
Dmytro
A Defias Bandit
Join Date: Dec 2022
Posts: 3
Question Anchoring FontStrings (Noob question)

Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\FrameXML\UI.xsd">
  <Frame name="SomeFrame">
    <Size x="200" y="300"/>
    <Anchors>
      <Anchor point="LEFT" relativeTo="UIParent" relativePoint="CENTER" />
    </Anchors>
    <Layers>
      <Layer level="BACKGROUND">
        <Texture name="$parentBgTexture" file="Interface\DialogFrame\UI-DialogBox-Background"/>
      </Layer>
      <Layer level="OVERLAY">
        <FontString text="String 11111" inherits="GameFontNormal">
          <Anchors>
            <Anchor point="TOP" relativeTo="Button1" relativePoint="BOTTOM"/>
          </Anchors>
        </FontString>
        <FontString text="String 2" inherits="GameFontNormal" name="String2">
          <Anchors>
            <Anchor point="TOP"  />
          </Anchors>
        </FontString>
      </Layer>
    </Layers>
    <Frames>
      <Button name="Button1" inherits="GameMenuButtonTemplate" text="Button1">
        <Anchors>
          <Anchor point="CENTER"/>
        </Anchors>
      </Button>
      <Button name="Button2" inherits="GameMenuButtonTemplate" text="Button2">
        <Anchors>
          <Anchor point="BOTTOM" relativeTo="Button1" relativePoint="TOP"/>
        </Anchors>

      </Button>
    </Frames>
  </Frame>
</Ui>
Hello, I'm new to wow xml and I have trouble anchoring FontString to Button1,Button2. Anchoring for parent frame works, but when I use <Anchor point="TOP" relativeTo="Button1" relativePoint="BOTTOM"/> on fontString, FontString just disappears, what's the correct way to do it?
  Reply With Quote
12-03-22, 08:35 AM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
A thing has to exist before you can anchor to it. Your widgets are created in the order they appear in the XML therefore Button1 doesn't exist at the time you are trying to anchor the fontstring.

As an aside, any widget with a name has that name placed in the global table as a reference. All addons including the entire Blizzard UI use the same global table so it is a good idea to make sure widget names are unique.

"Button1" cound be "$parentButton1" which you make its name "SomeFrameButton1", the "$parent" is replaced with the name of the parent widget.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
12-03-22, 10:47 AM   #3
Dmytro
A Defias Bandit
Join Date: Dec 2022
Posts: 3
Originally Posted by Fizzlemizz View Post
A thing has to exist before you can anchor to it. Your widgets are created in the order they appear in the XML therefore Button1 doesn't exist at the time you are trying to anchor the fontstring.

As an aside, any widget with a name has that name placed in the global table as a reference. All addons including the entire Blizzard UI use the same global table so it is a good idea to make sure widget names are unique.

"Button1" cound be "$parentButton1" which you make its name "SomeFrameButton1", the "$parent" is replaced with the name of the parent widget.
Thank you. That did help
Now I came to another problem, I can't move any <Button>, <FormString> on x\y axis with <Offset> what would be the issue here?
Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\FrameXML\UI.xsd">
  <Frame name="SomeFrame" parent="UIParent">

    <Size x="200" y="300"/>
    <Anchors>
      <Anchor point="TOP"/>
      <Offset>
        <AbsDimension x="31" y="-51" />
      </Offset>
    </Anchors>


    <Layers>
      <Layer level="BACKGROUND">
        <Texture name="$parentBgTexture" file="Interface\DialogFrame\UI-DialogBox-Background"/>
      </Layer>
      <Layer level="OVERLAY">
        <FontString text="String 1" name="$parent_String1" inherits="GameFontNormal">

          <Anchors>
            <Anchor point="CENTER" />
            <Offset>
              <AbsDimension x="31" y="-151" />
            </Offset>
          </Anchors>
        </FontString>
        <FontString text="String 2" inherits="GameFontNormal" name="$parent_String2">
          <Anchors>
            <Anchor point="TOP" relativeTo="$parent_String1" relativePoint="BOTTOM"/>
            <Offset>
              <AbsDimension x="1" y="-81" />
            </Offset>
          </Anchors>
        </FontString>
      </Layer>
    </Layers>
    <Frames>
      <Button name="$parent_Button1" inherits="GameMenuButtonTemplate" text="Button1">
        <Anchors>
          <Anchor point="TOP" relativePoint="BOTTOM" relativeTo="$parent_String1"/>
        </Anchors>
      </Button>
      <Button name="$parent_Button2" inherits="GameMenuButtonTemplate" text="Button2">
        <Anchors>
          <Anchor point="TOP" relativePoint="BOTTOM" relativeTo="$parent_String2"/>
          <Offset>
            <AbsDimension x="1" y="-81" />
          </Offset>
        </Anchors>
      </Button>
    </Frames>
  </Frame>
</Ui>
  Reply With Quote
12-03-22, 11:24 AM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
Code:
<Anchor point="TOP" relativePoint="BOTTOM" relativeTo="$parent_String2"/>
<Offset>
The <Offset... needs to be inside the <Anchor.. tags

Code:
<Anchor point="TOP" relativePoint="BOTTOM" relativeTo="$parent_String2">
         <Offset>
            <AbsDimension x="1" y="-81" />
          </Offset>
</Anchor>
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
12-03-22, 12:41 PM   #5
Dmytro
A Defias Bandit
Join Date: Dec 2022
Posts: 3
Originally Posted by Fizzlemizz View Post
Code:
<Anchor point="TOP" relativePoint="BOTTOM" relativeTo="$parent_String2"/>
<Offset>
The <Offset... needs to be inside the <Anchor.. tags

Code:
<Anchor point="TOP" relativePoint="BOTTOM" relativeTo="$parent_String2">
         <Offset>
            <AbsDimension x="1" y="-81" />
          </Offset>
</Anchor>
OMG, ty dude how did I miss that, fml
u the best
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Anchoring FontStrings (Noob question)

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off