Talk:API GameTooltip SetHyperlink

From Wowpedia
Jump to: navigation, search

Please note the differences between table.fn() and table:fn(). They are critical differences. Thus, you both were right when going back and forth in your edits. However, the example listed was slightly wrong; I touched it up. --Shirik 11:26, 17 April 2007 (EDT)

Reverted it, pretty much every other example on the wiki is using table:fn() not table.fn() so no sense in confusing people, you can test that it doesn't accept table:fn() by logging in game and running the example. --Shadow 11:34, 17 April 2007 (EDT)
You probably want to check out the difference between : and . which is described here (had to read the article, myself, to be absolutely sure :) ): http://www.lua.org/pil/16.html
As you can see there, SetHyperlink() indeed has a "hidden" first argument, like all other widget functions. If you call the function using :, the object itself will be passed as the functions first argument. That's why table:fn() isn't correct (since the table functions are not designed to receive a reference to their own object, whereas GameTooltip:SomeFunction() is).
Another quite common usage for the : is link:match(...), where link is a string. This equals the function call: string.match(link, ...).
So in our case the syntax should be either SetHyperlink(frame, link) or GameTooltip:SetHyperlink(link). Since all other widget functions I checked use the later style, I changed it accordingly.
--Luke1410 13:15, 17 April 2007 (EDT)
Right, but your example is frame:fn( otherFrame, link ) not frame.fn( otherFrame, link ) so it's incorrect regardless of what you can use in lua hence why it was changed. --Shadow 14:33, 17 April 2007 (EDT)
Absolutelty right. One thing I didn't realize until now. :) --Luke1410 16:19, 17 April 2007 (EDT)
Hehe, oh well it happens! --Shadow 17:13, 17 April 2007 (EDT)