Hi guys,
I'm trying to check whether a (virtual) control exists before I create it. This is the XML Code
Code:
<Label name="QuestLabel" virtual="true" font="ZoFontAnnounceMedium" text="">
<Anchor point="BOTTOMLEFT" relativeTo="$(parent)WindowTitle" relativePoint="BOTTOMLEFT" offsetX="50" offsetY="100" />
</Label>
And this is the lua code to create the control. This function gets called multiple times so I included code to check if the control already exists but it's not working
Lua Code:
function TestAddon:CreateQuestLabel(questID, labelName, containingControl, yOffset)
local label = containingControl:GetNamedChild(labelName) --containingControl would be $(parent)
if label == nil then
label = CreateControlFromVirtual(labelName, containingControl, "QuestLabel")
--Fails here "Failed to create Control "QuestLabel1". Duplicate Name
end
label:SetText(questID .. " - " .. TestAddon:GetQuestName(questID))
label:SetAnchor(BOTTOMLEFT, TestAddonGridWindowTitle, BOTTOMLEFT, 50, yOffset)
return label
end
Does anyone know why this does not work? Thanks!