View Single Post
05/19/14, 05:42 AM   #6
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Loaf View Post
Hi, had same issue with my own dynamically created buttons. Found from Zgoo that "i" was not being appended to the name how it was supposed to from wiki, so buttons were all "DynamicButton". Found I had to do: (obviously without the "ZO_FriendsListList" bit!)
Code:
for i = 1, 10 do
    local dynamicControl = CreateControlFromVirtual("DynamicButton" .. i, ZO_FriendsListList, "DynamicButton", i)
end
(also the "i" at the end could be omitted, seemed to do nothing!)
Buttons were then created with no errors and with differing names as they were supposed to.

Also I found that "DynamicButton2:SetText("2")" didn't change the label I had on the button. Changing the XML; removing the label part fixed it.
Code:
<Button name="DynamicButton" virtual="true" text="Click">
</Button>
Hope any of that helps.
Suffix is defined in global function CreateControlFromVirtual(...), so if you use this function it works just fine.
Please do not confuse that function with WINDOW_MANAGER:CreateControlFromVirtual(...).


EDIT: As to the original question I'd try to use default template instead of custom (this code works for me):
lua Code:
  1. for i, row in pairs(ZO_FriendsListList.activeControls) do
  2.    local button = CreateControlFromVirtual("DynamicButton", ZO_FriendsListList, "ZO_DefaultTextButton", i)
  3.    button:SetAnchor(RIGHT, row, LEFT, 50, 0)
  4.    button:SetText(tostring(i))
  5. end

Last edited by Garkin : 05/19/14 at 06:21 AM.
  Reply With Quote