View Single Post
06-05-13, 03:15 PM   #10
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Pre-hooking ChatEdit_InsertLink is a bad idea, as it will cause taint, and your particular hook is especially bad since you completely replicate the original function instead of just calling it -- so any time Blizzard changes the function, you either have to update your addon immediately, or you're breaking default UI functionality for your users.

You should use a secure post-hook instead:

Code:
hooksecurefunc("ChatEdit_InsertLink", function(link)
    if MyEditBox:IsVisible() and MyEditBox:HasFocus() then
        MyEditBox:Insert(link)
    end
end)
On a side note, upvaluing _G and then upvaluing _G.GetSpellInfo confers no benefit over just upvaluing GetSpellInfo directly -- and for code that only runs when the user shift-clicks a link in chat, there's no benefit in upvaluing anything at all. Just get rid of that clutter and make your code more readable.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote