From 22f8e7404614fd138e3aeb57f11e9d22eebd1002 Mon Sep 17 00:00:00 2001 From: Dusk-92 Date: Tue, 25 Aug 2026 18:02:02 +0200 Subject: [PATCH] Preserve existing chat hyperlink handlers --- mods/chat-tweaks.lua | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/mods/chat-tweaks.lua b/mods/chat-tweaks.lua index d80fc82..88ac58d 100644 --- a/mods/chat-tweaks.lua +++ b/mods/chat-tweaks.lua @@ -258,35 +258,55 @@ module.enable = function(self) frame:ShaguTweaksBaseAddMessage(text, a1, a2, a3, a4, a5) end - -- Item link tooltip on mouseover - _G["ChatFrame"..i]:SetScript("OnHyperlinkEnter", function() + local chatFrame = _G["ChatFrame"..i] + local baseHyperlinkEnter = chatFrame:GetScript("OnHyperlinkEnter") + local baseHyperlinkLeave = chatFrame:GetScript("OnHyperlinkLeave") + local baseHyperlinkClick = chatFrame:GetScript("OnHyperlinkClick") + + -- Add the item-link preview without discarding Turtle or addon handlers. + chatFrame:SetScript("OnHyperlinkEnter", function() local _, _, linktype = string.find(arg1, "^(.-):(.+)$") if linktype == "item" then + this.ShaguTweaksItemTooltip = true GameTooltip:SetOwner(this, "ANCHOR_CURSOR") GameTooltip:SetHyperlink(arg1) GameTooltip:Show() + elseif baseHyperlinkEnter then + baseHyperlinkEnter() end end) - _G["ChatFrame"..i]:SetScript("OnHyperlinkLeave", function() - GameTooltip:Hide() + + chatFrame:SetScript("OnHyperlinkLeave", function() + if this.ShaguTweaksItemTooltip then + this.ShaguTweaksItemTooltip = nil + GameTooltip:Hide() + elseif baseHyperlinkLeave then + baseHyperlinkLeave() + end end) - -- Alt/Ctrl-click player names; URL copy - _G["ChatFrame"..i]:SetScript("OnHyperlinkClick", function() + -- Handle only ShaguTweaks-specific actions, otherwise preserve the + -- chat frame's existing hyperlink behavior. + chatFrame:SetScript("OnHyperlinkClick", function() local _, _, playerLink = string.find(arg1, "(player:.+)") if playerLink then local _, pname = strsplit(":", playerLink) if API.IsAltKeyDown and API.IsAltKeyDown() then InviteByName(pname) + return elseif API.IsControlKeyDown and API.IsControlKeyDown() then TargetByName(pname, true) - else - ChatFrame_OnHyperlinkShow(arg1, arg2, arg3) + return end elseif strsub(arg1,1,3) == "url" then if string.len(arg1) > 4 and string.sub(arg1,1,4) == "url:" then CopyLinkDialog.CopyText(string.sub(arg1, 5)) end + return + end + + if baseHyperlinkClick then + baseHyperlinkClick() else ChatFrame_OnHyperlinkShow(arg1, arg2, arg3) end