local link = "|cff71d5ff|Hitem:12345:0:0:0:0:0:0:0:0:0|h[Example Item]|h|r"
local macro = "/script ChatFrame1:AddMessage('" .. link .. "', 1, 1, 0)"
local frame = CreateFrame("Button", nil, UIParent, "SecureActionButtonTemplate")
frame:SetHeight(20)
frame:SetWidth(100)
frame:SetPoint("CENTER")
frame:SetScript("OnClick", function(self, button, down)
if button == "LeftButton" and not IsShiftKeyDown() then
-- Open the item normally if left clicked without shift
_G[macro]()
elseif button == "LeftButton" and IsShiftKeyDown() then
-- Open the link in the chat frame if left clicked with shift
ChatFrame_OpenChat(link)
end
end)
frame:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText("Click to Open Item")
GameTooltip:Show()
end)
frame:SetScript("OnLeave", function(self)
GameTooltip:Hide()
end)
frame:RegisterForClicks("LeftButtonUp")
frame:SetNormalTexture("Interface\\Buttons\\UI-Panel-Button-Up")
frame:SetPushedTexture("Interface\\Buttons\\UI-Panel-Button-Down")
frame:SetHighlightTexture("Interface\\Buttons\\UI-Panel-Button-Highlight")
local text = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
text:SetPoint("CENTER")
text:SetText("Click Me!")
In this example, we create a button frame that acts as a clickable link. When the button is left-clicked without the shift key, it executes a macro that adds a message to the default chat frame. When the button is left-clicked with the shift key, it opens the link directly in the chat frame.