WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   XML StatusBar help (https://www.wowinterface.com/forums/showthread.php?t=52004)

Mugi 02-27-15 05:39 PM

XML StatusBar help
 
Hiya, I can't seem to get a StatusBar to be created and displayed. Here is the current version of my status bar:

Code:

<StatusBar name="$parent_status" minValue="0" maxValue="100" defaultValue="30" orientation="HORIZONTAL">
        <Scripts>
                <OnLoad>print("start")</OnLoad>
        </Scripts>
        <Size x="150" y="30"/>
        <Anchors>
                <Anchor point="CENTER" relativePoint="CENTER" relativeTo=""/>
        </Anchors>
        <BarColor r="1.0" g="0" b="0"/>
</StatusBar>

Previously I have tried inheriting various StatusBar templates, explicitly setting a bar texture, and a few other different variations of this type of template, but the onload script never runs, and I can see the bar is not added to my frame when using the framestack.

Anyone know what I'm missing?

Duugu 02-27-15 07:02 PM

A parent object?

Phanx 02-27-15 10:29 PM

You either need a parent (highly recommended) or a valid attribute for your anchor's "relativeTo" attribute.

If your frame is logically attached to another frame (eg. you're adding another statusbar to the player frame) use that frame as its parent. If your frame is standalone, parent it to the UIParent. Without a parent (or some chain of parentage that leads to the UIParent) your frame will not respect UI scaling changes and won't be hidden when the user presses Alt-Z to hide the UI (eg. when taking a screenshot).

Also, the "$parent" token in a frame name should never be used if your frame doesn't have a parent, and should generally not be used if your frame's parent is part of the default UI or some other addon, since it may override something else that already exists, or result in other unexpected behavior. Make sure your frame's name is unique (so it won't conflict with other frames) and clearly identifies your addon (so users can figure out what addon that statusbar they want to move belongs to by using the "/framestack" command or other tools).

Mugi 02-28-15 05:42 AM

Hi sorry for the confusion, I just posted the relevant part of the XML - the fragment I posted is inside a grey parent frame which is loading and displaying just fine. When I get back to my PC I will try removing the relativeTo property from the anchor tag and see if it loads properly.

Mugi 02-28-15 01:30 PM

OK removing the relativeTo property did not cause the scrollbar to load. Anything else i'm missing here?

Phanx 02-28-15 11:34 PM

Post your entire code. Posting random snippets is worse than useless, especially when you don't even mention that what you posted isn't your entire code.

Mugi 03-03-15 02:45 PM

OK, apparently I didn't say so clearly enough in my first post. Here is what I have:

xml: http://pastebin.com/MAKAqg78

lua: http://pastebin.com/70yzSABc

Again, I assume i'm missing some value in my StatusBar XML that is necessary, but I can't seem to find any examples to copy from.

Duugu 03-03-15 03:05 PM

It's still the same problem. :) As Phanx already wrote:
Quote:

You either need a parent (highly recommended) or a valid attribute for your anchor's "relativeTo" attribute.
Enclose all of your child widgets in a <Frames></Frames> tag (http://wow.gamepedia.com/XML/Frames), OR set the relativeTo="" attribute (http://wow.gamepedia.com/XML_Properties#anchors) within the statusbar anchor to the parent frame ("DougFrame" in your case).

Mugi 03-03-15 04:03 PM

Hmm, I must be misunderstanding what you mean by a parent. From my point of view, the parent of the StatusBar is DougFrame. When inspecting the result using /framestack, I can see that my FontString, which i've labelled as $parent_text, is named as "DougFrame_text". Is there some problem with how I have situated the bar inside those Layer tags?

After some mucking about, I moved the statusbar out of the frame structure entirely and just set it's parent attribute to DougFrame, which caused it to load properly. So it does work at least, but i'm not sure why.

Mugi 03-03-15 04:21 PM

Ahh, I misspelled my "Frames" element as "Frame". Sorry, I did not realise these were two different elements. Working now, thanks for your help!


All times are GMT -6. The time now is 06:55 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI