title: Issue with code using Interface Options Addon in World of Warcraft
body: <p>I am writing a UI to a pre-existing addon. Or, more specifically, adding configuration options and trying to take advantage of the Interface Options Addons (IOA) panel. I've been referencing wowwiki, specifically the <a href="http://www.wowwiki.com/Using_the_Interface_Options_Addons_panel" rel="nofollow noreferrer">page that talks about using that panel</a>, but more generally a bunch of pages.</p>
  
  <p>I'm running into a problem that I'm sure is just a result of my inexperience writing addons (I've written a few, but it's a learning experience every time). The basic concept is:</p>
  
  <ul>
  <li>Create the main panel - using XML</li>
  <li>Create sub-items for things that should be visible on the main panel (is, global options) - using XML</li>
  <li>Create a sub-panel for each child item (configuration category) - using Lua (the number and names of the sub-panels is dynamic)</li>
  <li>Create sub-items for each sub-panel - using Lua</li>
  </ul>
  
  <p>The things that work are:</p>
  
  <ul>
  <li>The main panel shows up in the IOA panel</li>
  <li>The sub panels show up in the IOA panel, as sub-items of the main panel</li>
  <li>The textures I put on the sub panels show up on them</li>
  </ul>
  
  <p>The problems I'm having are:</p>
  
  <ul>
  <li>If I create the sub-panels as children of the main panel, they show up on top of the main panel</li>
  <li>If I create the sub-panels are children of the UIParent, they show up on the main screen (visible when the IOA window isn't open</li>
  <li>Nothing I create in the XML file as a child Frame of the main panel shows up on it</li>
  </ul>
  
  <p>The code I have so far (clipped for brevity) is at the bottom of the message. Any help/suggestions would be more than appreciated. I know there's a lot in the code section, but I wanted to be as clear as I could about what I was doing.</p>
  
  <p>Note that I did post about this on the official Warcraft UI forum, but was unable to get any help there.</p>
  
  <p><strong>embeds.xml</strong></p>
  
  <pre><code>...snip...
  &lt;Frame name="MyAddonFrame" parent="UIParent" hidden="false"&gt;
    &lt;Scripts&gt;
      &lt;OnLoad&gt;
        self:RegisterEvent("UNIT_TARGET");
        self:RegisterEvent("PLAYER_ENTERING_WORLD");
        MyAddon_OnLoad(self);
      &lt;/OnLoad&gt;
      &lt;OnEvent function="MyAddon_OnEvent" /&gt;
      &lt;/Scripts&gt;
  
      &lt;Frames&gt;
        &lt;Frame parent="MyAddonFrame" inherits="UIDropDownMenuTemplate"&gt;
          &lt;Frames&gt;
            &lt;Button name="MyAddon_MacroSelectDropdownButton"&gt;
              &lt;Anchors&gt;
                &lt;Anchor point="CENTER"/&gt;
              &lt;/Anchors&gt;
  
              &lt;Scripts&gt;
                &lt;OnLoad&gt;
                  UIDropDownMenu_Initialize(this,
                  MyAddon_MacroSelectDropdown_OnLoad);
                &lt;/OnLoad&gt;
                &lt;OnClick&gt;
                  MyAddon_MacroSelectDropdownButton_OnClick();
                &lt;/OnClick&gt;
              &lt;/Scripts&gt;
            &lt;/Button&gt;
            &lt;MessageFrame&gt;
              &lt;Anchors&gt;
                &lt;Anchor point="CENTER"/&gt;
              &lt;/Anchors&gt;
            &lt;FontString text="Message Frame"/&gt;
          &lt;/MessageFrame&gt;
        &lt;/Frames&gt;
      &lt;/Frame&gt;
    &lt;/Frames&gt;
  &lt;/Frame&gt;
  ...snip...
  </code></pre>
  
  <p><strong>Lua Code</strong></p>
  
  <pre><code>...snip...
  function MyAddon_OnLoad(panel)
      MyAddon_CreateOptionsPanel(panel);
      MyAddon_ConsoleMessage("Loaded MyAddon: " .. tostring(panel));
  end
  
  function MyAddon_CreateOptionsPanel(panel)
      panel.name = "MyAddon " .. GetAddOnMetadata("MyAddon", "Version");  -- Set the name for the Category for the Panel
      panel.okay = function (self) MyAddonFrame_Close(); end;                 -- When the player clicks okay, run this function.
      panel.cancel = function (self)  MyAddonFrame_CancelOrLoad();  end;  -- When the player clicks cancel, run this function.
      InterfaceOptions_AddCategory(panel);                                    -- Add the panel to the Interface Options
  
      for name,text in pairs(ConfigData) do
          MyAddon_CreateMacroPanel(name, panel, panel.name);
      end
  end
  
  function MyAddon_CreateMacroPanel(macroName, parent, parentName)
      MyAddon_ConsoleMessage("Added macro option pane: " .. macroName);
      panel = CreateFrame( "Frame", "MyAddon_MacroPanel_" .. macroName, parent);
      panel.name = macroName;
      panel.parent = parentName;
      InterfaceOptions_AddCategory(panel);
  
      -- create a backdrop so we can see that the panel is created
      panel:SetFrameStrata("BACKGROUND");
      panel:SetWidth(128); -- Set these to whatever height/width is needed 
      panel:SetHeight(64); -- for your Texture
  
      local t = panel:CreateTexture(nil,"BACKGROUND");
      t:SetTexture("Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Factions.blp");
      t:SetAllPoints(panel);
      panel.texture = t;
  
      panel:SetPoint("CENTER",0,0);
  end
  
  
  
  -- MyAddon_MacroSelectDropdown
  function MyAddon_MacroSelectDropdown_OnLoad()
      info            = {};
      info.text       = "Auto";
      info.value      = "Auto";
      -- FunctionCalledWhenOptionIsClicked 
      info.func       = function (self) MyAddon_SetMacroAuto(); end;
      UIDropDownMenu_AddButton(info);
      for index,macro in pairs(ConfigData) do
          info.text       = name;
          info.value      = name;
          -- FunctionCalledWhenOptionIsClicked 
          info.func       = function (self) MyAddon_SetMacroByName(name); end;
          UIDropDownMenu_AddButton(info);
      end
      -- can also be done as function() FunctionCalledWhenOptionIsClicked() end;
  end
  ...snip...
  </code></pre>