-
Posted by GMan on Wed, 02 Jun 2010 17:33:26
I'm a little stumped on an issue surrounding using frame templates. In my XML I have a template defined. The template essential contains a single row and each row has a button / statusbar / button. Here is the XML code ...
<Frame name="DrWho_UnitFrameTemplate" inherits="DrWho_MainFrame" virtual="true"> <Size x="124" y="12" /> <Frames> <Button name="$parentTankButton"> <NormalTexture file="Interface\AddOns\DrWho\DrWho.tga"/> <Size x="10" y="10"/> <Anchors> <Anchor point="TOPLEFT" relativePoint="TOPLEFT"> <Offset x="1" y="-1"/> </Anchor> </Anchors> </Button> <StatusBar name="$parentHealthBar" minvalue="0" maxvalue="100" defaultvalue="100"> <BarColor r="0.0" g="1.0" b="0.0" a="1.0"/> <BarTexture file="Interface\AddOns\DrWho\DrWho.tga"/> <Size x="100" y="10"/> <Anchors> <Anchor point="TOPLEFT" relativePoint="TOPLEFT"> <Offset x="12" y="-1"/> </Anchor> </Anchors> </StatusBar> <Button name="$parentMobTypeButton"> <NormalTexture file="Interface\AddOns\DrWho\DrWho.tga"/> <Size x="10" y="10"/> <Anchors> <Anchor point="TOPLEFT" relativePoint="TOPLEFT"> <Offset x="113" y="-1"/> </Anchor> </Anchors> </Button> </Frames> </Frame>
I create several instance of this object in my LUA code like ...
u
nits[guid]["frame"] = CreateFrame("Frame", guid, DrWho_MainFrame, "DrWho_UnitFrameTemplate")
I can use the various template frame widget methods (Show, Hide, etc.) by referencing ...
units[guid]["frame"]:<method name>
I can not seem to figure out how to reference the template frames child widgets ($parentTankButton, $parentHealthBar, $parentMobTypeButton) and use those methods ... (i.e. SetMinMaxValue and SetValue on the statusbar).
I can essentially manually hard code all of the rows in the XML and directly use the child widget methods based upon the names, but I would much prefer to use templates to keep things tiddy.
Any help would be appreciated ... Thanks!
-
Posted by jnwhiteh on Wed, 02 Jun 2010 18:30:21
You can use the parentKey attribute on those elements, and that key will be set in the parent so you can access it easily. In this case if you add
parentKey="tankButton"
to the tank button sub-frame, you'll be able to access it using parent.tankButton. That's the easiest way to do it, and much easier than what we used to have to do! -
Posted by GMan on Thu, 03 Jun 2010 15:03:37
Thank you so much ... worked like a charm!