Quantcast ESOUI - View Single Post - Check if control exists
View Single Post
10/05/17, 12:51 PM   #1
ObjectMetadata's Avatar
Join Date: Oct 2017
Posts: 7
Check if control exists

Hi guys,
I'm trying to check whether a (virtual) control exists before I create it. This is the XML Code
<Label name="QuestLabel" virtual="true" font="ZoFontAnnounceMedium" text="">
	<Anchor point="BOTTOMLEFT" relativeTo="$(parent)WindowTitle" relativePoint="BOTTOMLEFT" offsetX="50" offsetY="100" />
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:
  1. function TestAddon:CreateQuestLabel(questID, labelName, containingControl, yOffset)
  2.     local label = containingControl:GetNamedChild(labelName) --containingControl would be $(parent)
  3.     if label == nil then
  4.         label = CreateControlFromVirtual(labelName, containingControl, "QuestLabel")
  5.         --Fails here "Failed to create Control "QuestLabel1". Duplicate Name
  6.     end
  7.     label:SetText(questID .. " - " .. TestAddon:GetQuestName(questID))
  8.     label:SetAnchor(BOTTOMLEFT, TestAddonGridWindowTitle, BOTTOMLEFT, 50, yOffset)
  9.     return label
  10. end

Does anyone know why this does not work? Thanks!
  Reply With Quote