Originally Posted by zgrssd
I think I get it. The template was not properly put into <GuiXml> and <Controls> Tags. Hence the template was never properly read and could not be found
After solving this issues and some minor issue with the retreival of data I have anotehr issue:
Nothing is shown in the window. I double checked by giving the lables text and putting d(row) into the code - it is executed and the items are created. They are just not shown.
I asume that I am adding them on a level too high or that something in my window is wrong.
|
Its because rows are not properly anchored to the window.
Try this code:
xml Code:
<GuiXml>
<Controls>
<Control name="EventExplorerRow" virtual="true">
<Dimensions y="25"/>
<Controls>
<Label name="$(parent)Id" font="ZoFontGame" horizontalAlignment="RIGHT">
<Dimensions x="60"/>
<Anchor point="LEFT" />
</Label>
<Label name="$(parent)Name" font="ZoFontGame">
<Anchor point="LEFT" relativeTo="$(parent)Id" relativePoint="RIGHT" offsetX="20"/>
</Label>
</Controls>
</Control>
<TopLevelControl name="EventExplorerWindow" mouseEnabled="true" movable="true" clampedToScreen="true" hidden="true">
<Dimensions x="760" y="650" />
<Anchor point="CENTER" />
<Controls>
<Label name="$(parent)Title" inherits="ZO_WindowTitle" text="Event Explorer" />
<Button name="$(parent)Close" inherits="ZO_CloseButton">
<Anchor point="TOPRIGHT" offsetY="3" />
<OnClicked>
EventExplorerWindow:SetHidden(true)
</OnClicked>
</Button>
<Control name="$(parent)Container" inherits="ZO_ScrollContainer">
<Anchor point="TOPLEFT" offsetY="30" />
<Anchor point="BOTTOMRIGHT" />
</Control>
<Backdrop name="$(parent)BG" inherits="ZO_DefaultBackdrop" />
</Controls>
</TopLevelControl>
</Controls>
</GuiXml>
Lua Code:
local LCM = LibStub("LibConstantMapper")
local dataList = {}
local lastRow
--get the list of Events
local Events = LCM:getDataByMapping("Events")
local function fillWindow()
for key, value in ipairs(Events) do
local row = CreateControlFromVirtual("$(parent)Row", EventExplorerWindowContainerScrollChild, "EventExplorerRow", key)
if key == 1 then
row:SetAnchor(TOPLEFT, EventExplorerWindowContainerScrollChild, TOPLEFT, 0, 0)
else
row:SetAnchor(TOP, lastRow, BOTTOM, 0, 0)
end
row:GetNamedChild("Id"):SetText(tostring(value.value))
row:GetNamedChild("Name"):SetText(value.key)
lastRow = row
end
end
local function windowToggle()
EventExplorerWindow:SetHidden(not EventExplorerWindow:IsHidden())
end
local function OnAddOnLoaded(eventID, AddonName)
if (AddonName~= "EventExplorer") then return end
fillWindow()
SLASH_COMMANDS["/eventexplo"] = windowToggle
end
EVENT_MANAGER:RegisterForEvent("MyAddOn", EVENT_ADD_ON_LOADED, OnAddOnLoaded)
EDIT:
By the way list of events in your library contains global reference to EVENT_MANAGER.
Updated mapping:
lua Code:
{ mapping = "Events", pattern = "^EVENT_", exclude = "^EVENT_MANAGER"},