Fizzlemizz - HandleModifiedItemClick

Requesting Support

Hello UI and Macro forums, and Fizzlemizz if you happen upon this. 

The Issue

  • ChatEdit_InsertLink has been depreciated
  • HandleModifiedItemClick does not work linking spells and talents
  • SetItemRef is the same problem as HandleModifiedItemClick
ChatEdit_InsertLink SetItemRef HandleModifiedItemClick
NO YES* YES*
I am at a loss here, and could use some guidance regarding 
these API. For context my addon uses and EditBox for taking
input. Hooking SetItemRef and HandleModifiedItemClick  will
allow me to shift+click items from my bags and default Chat
frame but fails to pass the ref with each hook when attempting
to link a spell or talent from their respective UI frames.

For reference here is the snippet of code Im playing with at the moment:

local inputBox = CreateFrame("EditBox", nil, GuildChatWindow, "InputBoxTemplate")
inputBox:SetSize(400, 35)
inputBox:SetPoint("BOTTOM", GuildChatWindow, "BOTTOM", 0, 35)
inputBox:SetAutoFocus(false)                                  
inputBox:EnableMouse(true)
inputBox:SetHyperlinksEnabled(true)
inputBox:SetMaxLetters(3999)
inputBox:SetScript("OnMouseDown", function(self)
    self:SetFocus()
end)
hooksecurefunc("HandleModifiedItemClick", function(link)
    inputBox:Insert(link)
end)
hooksecurefunc("SetItemRef", function(link)
    inputBox:Insert(link)
end)

This is working great for linking from bags and default chat frame as mentioned, am I not grabbing a parameter or hooking the wrong API or has Spells and Talent links been put "in a box" to limit / stop combat abuse?

Thanks for taking the time to read this and if you have any answers to this I would be so grateful.

Sincerly,
Lazyeyez aka Darthterac

Try playing with (replace inputBox:SetText with your :Insert(...) code or whatever works):

local owner = {}
EventRegistry:RegisterCallback("TalentButton.OnClick", function(owner, self, button)
	local spellID = self:GetSpellID();
	if spellID then
		local spellLink = C_Spell.GetSpellLink(spellID)
		inputBox:SetText(spellLink)
	end
end, owner)

EventRegistry:RegisterCallback("SpellBookItemMixin.OnModifiedClick", function(owner, self, button)
	local chatLink = C_SpellBook.GetSpellBookItemTradeSkillLink(self.slotIndex, self.spellBank);
	if not chatLink then
		-- If spell is not a trade skill, use regular spell link
		chatLink = C_SpellBook.GetSpellBookItemLink(self.slotIndex, self.spellBank);
	end
	inputBox:SetText(chatLink)
end, owner)
1 Like

THANK YOU

Fizzle You are amazing
Your code works fine and shows mastery
I never even came across anything like this 
researching the issue. Just one issue and 
I should look it up but Ill ask you - linking 
from professions ie. Shift+Click fishing not
working you wouldn't happen to know the 
correct API to include that by chance?

I need to hybrid this code with the hook for linking from bags still, but definitely 90% there.

YOURE THE BEST

Bags don’t have a registry event. If what you have works then it works…

Assumes using the same owner:

EventRegistry:RegisterCallback("ProfessionSpellButton.OnModifiedClick", function(owner, self, button)
	local slotIndex = ProfessionsBook_GetSpellBookItemSlot(self)
	local activeSpellBank = Enum.SpellBookSpellBank.Player
	if not slotIndex then
		return
	end
	local tradeSkillLink = C_SpellBook.GetSpellBookItemTradeSkillLink(slotIndex, activeSpellBank)
	if tradeSkillLink then
		inputBox:SetText(tradeSkillLink)
	else
		local spellLink = C_SpellBook.GetSpellBookItemLink(slotIndex, activeSpellBank)
		inputBox:SetText(spellLink)
	end
end, owner)
1 Like

I dont know if Ill ever be able to thank you enough but your in the comments of my addon a few times. Thanks for being so helpful on these forums.

1 Like