View Single Post
06-05-13, 07:15 PM   #14
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Based on the addon's description and code, it looks like the only thing it does is put the raw item link into the macro instead of just the item's name. Accordingly, the following code should work (for all link types, even). After the original ChatEdit_InsertLink function has run, it will check if the macro edit box has focus. If so, it will check if the macro already contains the link name. If not, it will insert the raw link.

This should work, because if the original function would handle the link (eg. shift-clicking a spell for a /cast command) then once your function runs, the edit box will already contain the link name (eg. the name of the spell).

Code:
hooksecurefunc("ChatEdit_InsertLink", function(link)
	if MacroFrameText and MacroFrameText:HasFocus() then
		local text = MacroFrameText:GetText()
		local name = strmatch(link, "%[(.-)%]")
		if not strfind(text, name, 1, true) then
			MacroFrameText:Insert(link)
		end
	end
end)
If you really only want it to work for links, change it accordingly:
Code:
	if MacroFrameText and MacroFrameText:HasFocus() and strfind(link, "|Hitem:", 1, true) then
__________________
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