Quantcast
WoWInterface - View Single Post - LFG Applicant Tooltip hook?
View Single Post
05-06-18, 02:30 PM   #9
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
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".
__________________
Author/maintainer of Grid, PhanxChat, oUF_Phanx, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!

Last edited by Phanx : 05-23-18 at 01:11 AM.
  Reply With Quote