Thread Tools Display Modes
02-27-15, 05:39 PM   #1
Mugi
A Murloc Raider
Join Date: Feb 2015
Posts: 6
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?
  Reply With Quote
02-27-15, 07:02 PM   #2
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
A parent object?
  Reply With Quote
02-27-15, 10:29 PM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
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).
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 02-27-15 at 10:31 PM.
  Reply With Quote
02-28-15, 05:42 AM   #4
Mugi
A Murloc Raider
Join Date: Feb 2015
Posts: 6
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.
  Reply With Quote
02-28-15, 01:30 PM   #5
Mugi
A Murloc Raider
Join Date: Feb 2015
Posts: 6
OK removing the relativeTo property did not cause the scrollbar to load. Anything else i'm missing here?
  Reply With Quote
02-28-15, 11:34 PM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
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.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
03-03-15, 02:45 PM   #7
Mugi
A Murloc Raider
Join Date: Feb 2015
Posts: 6
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.
  Reply With Quote
03-03-15, 03:05 PM   #8
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
It's still the same problem. As Phanx already wrote:
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).

Last edited by Duugu : 03-03-15 at 03:10 PM.
  Reply With Quote
03-03-15, 04:03 PM   #9
Mugi
A Murloc Raider
Join Date: Feb 2015
Posts: 6
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.
  Reply With Quote
03-03-15, 04:21 PM   #10
Mugi
A Murloc Raider
Join Date: Feb 2015
Posts: 6
Ahh, I misspelled my "Frames" element as "Frame". Sorry, I did not realise these were two different elements. Working now, thanks for your help!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » XML StatusBar help

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