Thread Tools Display Modes
03-31-16, 11:41 AM   #1
hsammyw
A Defias Bandit
Join Date: Mar 2016
Posts: 2
Why SetAllPoints?

I am trying to understand why I need to use SetAllPoints when creating a button in lua without a template vs with one. Here is the code that I'm using.

Lua Code:
  1. local myButton1 = CreateFrame("Button", "TestButton1", UIParent)
  2. myButton1:SetSize(64, 64)
  3. myButton1:SetPoint("TOP", 32, 0)
  4. myButton1.icon = myButton1:CreateTexture("$parentIconTexture", "BORDER")
  5. myButton1.icon:SetTexture("Interface\\ICONS\\INV_Misc_Fish_58")
  6. myButton1.icon:SetAllPoints() -- why?
  7.  
  8. local myButton2 = CreateFrame("Button", "TestButton2", UIParent, "TestButtonTemplate")
  9. myButton2:SetSize(64, 64)
  10. myButton2:SetPoint("TOP", -32, 0)
  11. myButton2.icon:SetTexture("Interface\\ICONS\\INV_Misc_Fish_57")

xml Code:
  1. <Button name="TestButtonTemplate" virtual="true">
  2.   <Layers>
  3.     <Layer level="BORDER">
  4.       <Texture name="$parentIconTexture" parentKey="icon"/>
  5.     </Layer>
  6.   </Layers>
  7. </Button>

You can see that I have to use(?) SetAllPoints in order for the texture to show up. What's the reason?

Thanks!
  Reply With Quote
03-31-16, 11:46 AM   #2
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
Using XML, the points of a region are automatically matched to its parent unless you specify size and anchor. In plain lua, you're just creating a texture region without specifying where to draw it.
__________________
  Reply With Quote
03-31-16, 12:21 PM   #3
hsammyw
A Defias Bandit
Join Date: Mar 2016
Posts: 2
I see! Thanks a ton. =)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Why SetAllPoints?


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