FrameXML $parent
I'm new to the Blizzard_FrameXML files and as kind of a self-tutorial I'm coloring as many default UI objects as I can (via SetVertexColor). In some cases the texture names I need aren't in the XML file associated with the object I'm trying to color. For example, trying to color the little dividers on the experience bar I couldn't find anything in MainMenuBar.xml that worked, but after looking at a few action bar addons I found MainMenuXPBarDiv(1, 2, 3, etc.) which does the trick.
I finished up the action bars & unit frames, and am now on the Minimap trying to color the tracking button (border). MiniMapMailBorder & MiniMapBattlefieldBorder appear in Minimap.xml, but the texture name for the tracking border is "$parentBorder" (yet all three share the same texure file path: Interface\Minimap\MiniMap-TrackingBorder). I also see other "$parent" strings (Icon, Background, etc) all over, and wondering how to find what they refer to (and how I can refer to whatever that is in my Lua function). Thanks! |
$parent is a substitute for the name of the parent object.
EG. Main Frame Name = MyFrame A Button associated with that frame that will act as an OK button = MyFrameButton. When the frame is created either using lua or xml with a parent value set then $parentButton will be the same thing. |
$parent is a key that gets replaced by the name of that widget's parent.
I don't use XML, so this is just some generic pseudo-code, but I think you'll get the gist. Code:
<Frame="MyFrame"> To get the name of something's parent via Lua, you do widget:GetParent(). /edit: heh - Xrystal and I used the same example! /edit2: note - $parent only works in XML, not Lua. |
I think I understand (I think) :p. Thank you both. What I'm doing is all in Lua, I'm just perusing the XML files to find the correct name of the thing I'm trying to color.
For example (using red for dramatic effect :)): Code:
for _, x in pairs({MinimapBorder, MiniMapMailBorder}) do Quote:
Code:
for _, x in pairs({MinimapBorder, MiniMapMailBorder, MiniMapTracking:GetParent(border)}) do Code:
<Frame name="MiniMapTracking"> |
In your example if you look at the XML file you have
<Frame name = "MiniMapTracking"> ... <Texture name="$parentBorder" .... .... This is the same as <Frame name = "MiniMapTracking"> ... <Texture name="MiniMapTrackingBorder" .... .... So using MiniMapTrackingBorder will get the object that is the border. |
Thanks Xrystal, it's working! MiniMapTrackingBorder doesn't work, but after doing another /framestack I realized the object is MiniMapTrackingButton (which doesn't appear at all in Minimap.xml :confused:). Taking what you said (adding Border) gives me the right object (MiniMapTrackingButtonBorder).
Looking again at Minimap.xml, I see the frame after MiniMapTracking is named $parentDropDown: Code:
<Frame name="$parentDropDown" inherits="UIDropDownMenuTemplate" clampedToScreen="true" id="1" hidden="true"> |
Yes .. $parentBorder is a child of $parentButton which in turn is a child of $parentDropDown from your example ... for it to show up as MiniMapTrackingButtonBorder means that somewhere in that XML there is something with either the name MiniMap and a $parentTracking child or something with the name MiniMapTracking
The XML file is structured so that <> tags are within each other so that inner tags are children of the tags surrounding them. EG: <Frame name="MyFrame"> <Frames> <Frame name="$parentBackground"> <Layer level = "BORDER"> <Texture name="$parentTexture"> </Texture> </Layer> </Frame> </Frames> </Frame> In this small example to access the full name of the texture you would have to discern each parents name portion until you get back to a full name. MyFrame MyFrameBackground MyFrameBackgroundTexture As you can see $parent is simply a way to use the name of the surrounding tag objects name without remembering how exactly you spelt it etc. Changing the base objects name will automatically reflect down the tags. If you changed MyFrame to MyMiniMap it would change the names as follows: MyMiniMap MyMiniMapBackground MyMiniMapBackgroundTexture I hope that helps you understand it a bit more. |
Quote:
|
Hi Aprikot,
In your code a few posts up, you wrote: Quote:
|
Thanks Akkorian. That was me taking the newb approach. :p
|
To add some interesting discoveries, $parent also works with most UI methods in Lua that accepts the frame name as a string.
|
Yep I am starting to use it more and more in my frame creation routines.
|
Quote:
|
It works exactly the same as in xml.
Code:
local a = CreateFrame("Frame", "MyFrame", UIParent) b) MyFrameButton c) MyFrameButtonTexture EDIT: Maybe I misunderstood your question.. leaving it anyway. :P |
Quote:
So, if MiniMapTracking was the name of the main frame and it had a button with the name $parentButton as a child then it's full name would be MiniMapTrackingButton. Likewise if $parentBorder is the child of $parentButton then tag Border at the end of the Buttons full name. |
Cool. So to access MiniMapTrackingButtonBorder in Lua without using the fully qualified texture name, would it look like this (using Ailae's example):
lua Code:
(MiniMapTracking frame in FrameXML\Minimap.xml for reference): xml Code:
|
Yes that would be the lua equivalent for those particular elements.
Looking at the xml itself the full hierarchy would be as follows: Code:
Main Frame : MiniMapTracking |
Sweet, thank you
|
I recently resumed pursuit of identifying & recoloring default UI textures, and am again confounded by the Minimap buttons. I'm as yet unable to figure out texture names for the below items (clockwise from top):
Code:
<Texture name="MiniMapMailBorder" urgency="5" file="Interface\Minimap\MiniMap-TrackingBorder"> The tracking button was an exception, which prompted this thread, and introduced me to tracing parent/child relationships in FrameXML. For the Zoom In/Out buttons, I see a different sort of exception: the textures appear to have no name at all, explicit or otherwise. For example, the only texture references contained in <Button name="MinimapZoomOut"></Button> are: Code:
<NormalTexture urgency="5" file="Interface\Minimap\UI-Minimap-ZoomOutButton-Up"/> |
|
All times are GMT -6. The time now is 11:23 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI