Quantcast Check if control exists - ESOUI
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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

ESOUI » Developer Discussions » Lua/XML Help » Check if control exists

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off