-
Posted by darkscion0 on Fri, 21 Sep 2012 16:08:02
Hello,
I have a frame that is created via XML and let's say the dimensions are 300 x 300. In order to add a 32x32 texture to that frame via LUA, can I just tag it onto the existing frame as a child or do I need to create a new frame in LUA with the desired dimensions, make it a child of the existing frame and then create a texture to SetAllPoints to the newly created frame?
Thanks
-
Posted by jnwhiteh on Fri, 21 Sep 2012 16:10:59
You can create the texture as a child of the existing frame without any issue. That's what the :CreateTexture() method does.
-
Posted by darkscion0 on Fri, 21 Sep 2012 16:42:11
Thanks. Judging from the replies to my other question, I was probably screwing up the SetPoint call for it.
-
Posted by darkscion0 on Fri, 21 Sep 2012 16:51:25
What's the proper way to call the global for the frame? If I have a frame created in XML called Testing can I use Testing:CreateTexture()?
-
Posted by jnwhiteh on Fri, 21 Sep 2012 17:32:23
Yes.
-
Posted by darkscion0 on Fri, 21 Sep 2012 17:33:41
Here's the specific scenario driving this discussion.
I have a frame called LRA that was created with XML. I can hide and show it with LRA:Hide()/LRA:Show() and the frame identifying macro show's it as LRA when I have my mouse over it.
The issue is the following code will display the new frame and texture, but they're parented to the UIParent/WorldFrame and I have no idea why it's not working.
f = CreateFrame("frame","$parentButtonFrame",LRA) f:SetFrameStrata("MEDIUM") f:SetWidth(32) f:SetHeight(32) local t = f:CreateTexture("$testIcon", "BACKGROUND") local _, class = UnitClass("player") local coords = CLASS_ICON_TCOORDS[class] t:SetTexture("Interface\\GLUES\\CHARACTERCREATE\\UI-CHARACTERCREATE-CLASSES") t:SetTexCoord(unpack(coords)) t:SetAllPoints(f) f:SetPoint("CENTER", LRA, "CENTER", 0, 0) f:Show()
As you can see I try to attach it both by making LRA the parent of $parentButtonFrame as well as trying to set the relativeTo in the new frame's SetPoint call. I'm at a loss and frustrated as hell. It's like the globals for the XML frames just aren't there to access from LUA.
-
Posted by darkscion0 on Fri, 21 Sep 2012 18:48:04
Ok, now I'm really confused.
I thought that there might have been an issue with the XML file creating the frame so I renamed my LRA.xml and added a new one which created the basic structure below. Both the frame and the texture are drawn, but the texture is still attached to UIParent.
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Script file="LRA.lua" /> <Frame name="LRA" parent="UIParent" toplevel="true"> <Size> <AbsDimension x="200" y="200" /> </Size> <Anchors> <Anchor point="TOPLEFT"> <Offset> <AbsDimension x="100" y="-150" /> </Offset> </Anchor> </Anchors> <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true"> <BackgroundInsets> <AbsInset left="11" right="12" top="12" bottom="11"/> </BackgroundInsets> <TileSize> <AbsValue val="32"/> </TileSize> <EdgeSize> <AbsValue val="32"/> </EdgeSize> </Backdrop> </Frame> </Ui>
-
Posted by darkscion0 on Fri, 21 Sep 2012 18:51:46
Disregard. I feel like an idiot. Checked my TOC file and it was loading the .LUA file before the .XML file. Changed up the order and it was fixed.