Accessing a frame created in XML from LUA
I've spent a week searching forums, and everything I've found leads me to believe that when a frame is created in XML, the reference is available in the global namespace with the same name as the frame. In other words, this should print "LUA Loaded", "ADDON_LOADED" and "XMLbeforeLUAForm" when the addon loads. The frame comes up visible, "LUA Loaded" prints, but nothing else. Can someone tell me where I'm going wrong? Thanks.
Code:
## Interface: 70000 Code:
<Ui xmlns="http://www.blizzard.com/wow/ui" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> Lua Code:
|
Change "self.name" to "self:GetName()".
If you want your frame to have a "name" key containing its name, you need to add that manually: local myFrame = XMLbeforeLUAForm |
Quote:
|
Thank you both very much. It looks like my entire problem was assuming that a frame object automatically has a name attribute; I'd also left out the SetScript(). This code works as I expected:
Code:
## Interface: 70000 Code:
<Ui xmlns="http://www.blizzard.com/wow/ui" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> Lua Code:
|
And here is your XML file as Lua code instead. (with tables expanded vertically for ease of reading)
Lua Code:
And you can add this right below that. Lua Code:
(BTW, it's Lua, not LUA. It's Portuguese for "moon", not an acronym.) (Oh, and also semi-colons are totally unnecessary in Lua. :) ) |
Quote:
Also, you should at the very least define what DrawLayer your regions reside in. Code:
luaFrame:CreateTexture("$parentTitleBorder","BORDER") |
Quote:
Thanks for all your comments. |
Yes. Children inherit visibility, alpha and scale from their parents.
|
All times are GMT -6. The time now is 12:00 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI