WoW:Hooking functions: Difference between revisions

({{UIHowTo}})
(Typo fixing using AWB)
Line 53: Line 53:
  ItemRefTooltip:Show(); ItemRefTooltip:Show();
  ItemRefTooltip:Show(); ItemRefTooltip:Show();
end</nowiki></pre></div>
end</nowiki></pre></div>
[[Image:Hooking_functions_demo.png|thumb|right|The resulting tooltip.]]
[[Image:Hooking functions demo.png|thumb|right|The resulting tooltip.]]
Explained in detail, the preceding code does:
Explained in detail, the preceding code does:
# Stores the old SetItemRef value (original function) into a local variable
# Stores the old SetItemRef value (original function) into a local variable
Line 59: Line 59:
# Extract known arguments from the vararg expression for local use.
# Extract known arguments from the vararg expression for local use.
# Check whether link text is a string, whether it matches [Tinfoil Hat], and whether we should display a tooltip
# Check whether link text is a string, whether it matches [Tinfoil Hat], and whether we should display a tooltip
# If all of the preceeding conditions are true, call our ShowTinfoilHat() function to construct the faux tooltip, and do not call the original handler.
# If all of the preceding conditions are true, call our ShowTinfoilHat() function to construct the faux tooltip, and do not call the original handler.
# Otherwise, call the original handler and let it handle the click.
# Otherwise, call the original handler and let it handle the click.
# Add a faux Tinfoil Hat item link to the chat frame to enable testing of this code.
# Add a faux Tinfoil Hat item link to the chat frame to enable testing of this code.
Anonymous user