View Single Post
09-27-16, 09:23 PM   #1
ruadh
A Murloc Raider
Join Date: Aug 2007
Posts: 5
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
## Title: XMLbeforeLUA
## Notes: How to address a frame created in XML from LUA run after the XML
## DefaultState: Enabled
## LoadOnDemand: 0
XMLbeforeLUAForm.xml
XMLbeforeLUA.lua
Code:
<Ui xmlns="http://www.blizzard.com/wow/ui" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Frame name="XMLbeforeLUAForm">
    <Size>
      <AbsDimension x="400" y="400" />
    </Size>
    <Anchors>
      <Anchor point="CENTER" relativeTo="UIParent">
      </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>
Lua Code:
  1. print("LUA loaded");
  2. local myFrame = XMLbeforeLUAForm;
  3. myFrame:SetScript("OnEvent", function(event) print(event); print(self.name); end)
  4. myFrame:RegisterEvent("ADDON_LOADED")

Last edited by ruadh : 09-27-16 at 09:26 PM.
  Reply With Quote