For things like this, rather than targeting specific objects by name in a list whose members are dynamically created, just hook the function that updates all the objects in the list, and hook each object if it isn't already hooked; this will catch new objects as they are created.
Code:
local hooked = {}
local function OnEnterHook(self)
if not self.tooltip then
-- The original OnEnter script doesn't show a tooltip in this case,
-- so we should exit here, instead of adding text to a tooltip that
-- isn't shown or, worse, is currently shown by something else.
return
end
GameTooltip:AddLine("hello world")
GameTooltip:Show()
end
hooksecurefunc(LFGListApplicationViewer_UpdateResults, function(self)
local buttons = self.ScrollFrame.buttons
for i = 1, #buttons do
local button = buttons[i]
if not hooked[button] then
button:HookScript("OnEnter", OnEnterHook)
hooked[button] = true
end
end
end)
If you need to get information about the result the tooltip is displayed for, the "self" in the OnEnterHook function refers to the InviteButton, which has an "applicantID" property, which can be passed to other functions to get whatever info you're looking for. See the
LFGListApplicationViewer_UpdateApplicant function for examples of getting the info; the "id" parameter passed into that function is your "applicantID".