View Single Post
08/29/19, 09:46 AM   #9
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,913
The setupCallback function runs as the rows are created and updated (on scroll). The rows are "reused" afaik like 12 rows are created (they are the visible rows) and if you scroll the setupCallback function will be call again and you only need to update the labels.

So be sure to create them only once and anchor them to the rowControl, set their parent to the rowControl so they hide with the row autoamtically.
And always check if the rowControl got the label already. If so, read your actual data from rowControl.dataEntry.data (or wherever you get the data from) and update the label with the actual rows data.
Otherwise each scroll would re-create another and another and another label and just show it on top of the others (if the name of the labels differ).

I'd use something like

Lua Code:
  1. local myLabelName = rowControl:GetName() .. "_myAddonLabel"
  2. local myLabel = WINDOW_MANAGER:GetControlByName(myLabelName, "")
  3. if not myLabel then
  4.     --I do not know the exact create control function anymore so just see this as example: name, parentControl, typeOfControl
  5.       myLabel = WINDOW_MANAGER:CreateControl(myLabelName, rowControl, CT_LABEL)
  6. end

Last edited by Baertram : 08/29/19 at 09:52 AM.
  Reply With Quote