Thank you guys for your help.
I got it working but I have two more problems. During the first search the code where I'm creating the label executes twice.
For example if there are 5 items in the first search results and 4 in the second search it executes 10 times during the first but 4 times during the second.
And the second problem is that the created label doesn't disappear when serch results change.
Here's the code:
Lua Code:
local count = 0
local function setupSearchResults()
local listView = TRADING_HOUSE.searchResultsList
if listView and listView.dataTypes and listView.dataTypes[1] then
local hookedFunctions = listView.dataTypes[1].setupCallback
listView.dataTypes[1].setupCallback = function(rowControl, slot)
--Call original function of the row
hookedFunctions(rowControl, slot)
--Do not execute if horse is changed
if SCENE_MANAGER:GetCurrentScene() ~= STABLES_SCENE then
count = count + 1
local label = CreateControl("Label" .. count, rowControl, CT_LABEL)
label:SetText(slot.purchasePrice)
label:SetFont("ZoFontGameLargeBold")
label:SetAnchor(CENTER, rowControl, CENTER, 50, 0)
end
end
end
end
local function OnAddOnLoaded(_, addOnName)
if addOnName ~= ADDON_NAME then
return
end
EVENT_MANAGER:UnregisterForEvent(ADDON_NAME, EVENT_ADD_ON_LOADED)
local ranInitialSetup = false
ZO_PreHook(
TRADING_HOUSE,
"SetCurrentMode",
function()
if (ranInitialSetup) then
return
end
ranInitialSetup = true
setupSearchResults()
end
)
end
EVENT_MANAGER:RegisterForEvent(ADDON_NAME, EVENT_ADD_ON_LOADED, OnAddOnLoaded)