Copy links with CopyToClipboard instead of a popup

Clicking a chat URL and the GUI's Donate/GitHub/Website buttons now put the address straight on the clipboard and say so in chat. The url link goes through ClassicAPI's LinkUtil handler registry, so SetItemRef is no longer replaced. Exporting a profile also copies the string.
This commit is contained in:
Brues
2026-10-30 23:45:08 -05:00
parent cff4be9416
commit ff5deac0ec
12 changed files with 24 additions and 70 deletions
+8
View File
@@ -579,6 +579,14 @@ function pfUI.api.SendChatMessageWide(msg)
SendChatMessage(msg,channel)
end
-- [ CopyText ]
-- Copies text to the clipboard and says so in chat
-- 'text' [string] the text to copy
function pfUI.api.CopyText(text)
CopyToClipboard(text)
DEFAULT_CHAT_FRAME:AddMessage("|cff33ffccpf|cffffffffUI|r: " .. T["Copied to clipboard"])
end
-- [ GroupInfoByName ]
-- Gets the unit id by name
-- 'name' [string] party or raid member
+1
View File
@@ -161,6 +161,7 @@ pfUI_translation["deDE"] = {
["Cooldown Text Time Threshold"] = nil,
["Coordinates Location"] = nil,
["Coordinates On Minimap"] = nil,
["Copied to clipboard"] = nil,
["Count"] = nil,
["Create Profile"] = nil,
["Ctrl-Click"] = nil,
+1
View File
@@ -167,6 +167,7 @@ pfUI_translation["enUS"] = {
["Cooldown Text Time Threshold"] = nil,
["Coordinates Location"] = nil,
["Coordinates On Minimap"] = nil,
["Copied to clipboard"] = nil,
["Count"] = nil,
["Create Profile"] = nil,
["Ctrl-Click"] = nil,
+1
View File
@@ -161,6 +161,7 @@ pfUI_translation["esES"] = {
["Cooldown Text Time Threshold"] = "Umbral del texto del tiempo de reutilización",
["Coordinates Location"] = "Coordenadas de localización",
["Coordinates On Minimap"] = "Coordenadas en el minimapa",
["Copied to clipboard"] = nil,
["Count"] = "Recuento",
["Create Profile"] = "Crear perfil",
["Ctrl-Click"] = "Ctrl-Clic",
+1
View File
@@ -161,6 +161,7 @@ pfUI_translation["frFR"] = {
["Cooldown Text Time Threshold"] = "Seuil du texte des temps de recharge",
["Coordinates Location"] = "Coordonnées Emplacement",
["Coordinates On Minimap"] = "Coordonnées sur la mini-carte",
["Copied to clipboard"] = nil,
["Count"] = "Compter",
["Create Profile"] = "Créer un profil",
["Ctrl-Click"] = "Ctrl-Clique",
+1
View File
@@ -161,6 +161,7 @@ pfUI_translation["koKR"] = {
["Cooldown Text Time Threshold"] = "재사용 대기시간 텍스트 임계 값",
["Coordinates Location"] = nil,
["Coordinates On Minimap"] = "미니맵의 좌표",
["Copied to clipboard"] = nil,
["Count"] = "카운트",
["Create Profile"] = "프로파일 생성",
["Ctrl-Click"] = nil,
+1
View File
@@ -161,6 +161,7 @@ pfUI_translation["ruRU"] = {
["Cooldown Text Time Threshold"] = "Порог текста восстановления",
["Coordinates Location"] = "Расположение координат",
["Coordinates On Minimap"] = "Координаты на миникарте",
["Copied to clipboard"] = nil,
["Count"] = "Счет",
["Create Profile"] = "Создать профиль",
["Ctrl-Click"] = "Ctrl+нажатие",
+1
View File
@@ -161,6 +161,7 @@ pfUI_translation["zhCN"] = {
["Cooldown Text Time Threshold"] = "技能冷却时间文字临界值",
["Coordinates Location"] = "坐标位置",
["Coordinates On Minimap"] = "小地图上的坐标",
["Copied to clipboard"] = nil,
["Count"] = "计数器",
["Create Profile"] = "新建配置",
["Ctrl-Click"] = "CTRL点击",
+1
View File
@@ -161,6 +161,7 @@ pfUI_translation["zhTW"] = {
["Cooldown Text Time Threshold"] = "技能冷卻時間文字臨界值",
["Coordinates Location"] = "座標位置",
["Coordinates On Minimap"] = "小地圖上的座標",
["Copied to clipboard"] = nil,
["Count"] = "計數器",
["Create Profile"] = "新建配置",
["Ctrl-Click"] = "CTRL點擊",
+4 -67
View File
@@ -145,7 +145,7 @@ pfUI:RegisterModule("chat", function ()
["URL"] = function(a1,a2,a3) return pfUI.chat:FormatLink(pfUI.chat.URLPattern.URL.fm,a1,a2,a3) end,
}
-- url copy dialog
-- url links
function pfUI.chat:FormatLink(formatter,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
if not (formatter and a1) then return end
local newtext = string.format(formatter,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
@@ -185,74 +185,11 @@ pfUI:RegisterModule("chat", function ()
return text
end
pfUI.chat.urlcopy = CreateFrame("Frame", "pfURLCopy", UIParent)
pfUI.chat.urlcopy:Hide()
pfUI.chat.urlcopy:SetWidth(270)
pfUI.chat.urlcopy:SetHeight(65)
pfUI.chat.urlcopy:SetFrameStrata("FULLSCREEN")
pfUI.chat.urlcopy:SetPoint("CENTER", 0, 0)
CreateBackdrop(pfUI.chat.urlcopy, nil, nil, 0.8)
pfUI.chat.urlcopy:SetMovable(true)
pfUI.chat.urlcopy:EnableMouse(true)
pfUI.chat.urlcopy:RegisterForDrag("LeftButton")
pfUI.chat.urlcopy:SetScript("OnDragStart",function()
this:StartMoving()
-- clicking a url link copies it
LinkUtil.RegisterLinkHandler("url", function(link, text, linkData)
CopyText(linkData.options)
end)
pfUI.chat.urlcopy:SetScript("OnDragStop",function()
this:StopMovingOrSizing()
end)
pfUI.chat.urlcopy:SetScript("OnShow", function()
this.text:HighlightText()
end)
pfUI.chat.urlcopy.text = CreateFrame("EditBox", "pfURLCopyEditBox", pfUI.chat.urlcopy)
pfUI.chat.urlcopy.text:SetTextColor(.2,1,.8,1)
pfUI.chat.urlcopy.text:SetJustifyH("CENTER")
pfUI.chat.urlcopy.text:SetWidth(250)
pfUI.chat.urlcopy.text:SetHeight(20)
pfUI.chat.urlcopy.text:SetPoint("TOP", pfUI.chat.urlcopy, "TOP", 0, -10)
pfUI.chat.urlcopy.text:SetFontObject(GameFontNormal)
CreateBackdrop(pfUI.chat.urlcopy.text)
pfUI.chat.urlcopy.text:SetScript("OnEscapePressed", function(self)
pfUI.chat.urlcopy:Hide()
end)
pfUI.chat.urlcopy.text:SetScript("OnEditFocusLost", function(self)
pfUI.chat.urlcopy:Hide()
end)
pfUI.chat.urlcopy.close = CreateFrame("Button", "pfURLCopyClose", pfUI.chat.urlcopy, "UIPanelButtonTemplate")
pfUI.api.SkinButton(pfUI.chat.urlcopy.close)
pfUI.chat.urlcopy.close:SetWidth(70)
pfUI.chat.urlcopy.close:SetHeight(18)
pfUI.chat.urlcopy.close:SetPoint("BOTTOMRIGHT", pfUI.chat.urlcopy, "BOTTOMRIGHT", -10, 10)
pfUI.chat.urlcopy.close:SetText(T["Close"])
pfUI.chat.urlcopy.close:SetScript("OnClick", function()
pfUI.chat.urlcopy:Hide()
end)
pfUI.chat.urlcopy.SetItemRef = SetItemRef
pfUI.chat.urlcopy.CopyText = function(text)
pfUI.chat.urlcopy.text:SetText(text)
pfUI.chat.urlcopy:Show()
end
function _G.SetItemRef(link, text, button)
if (strsub(link, 1, 3) == "url") then
if string.len(link) > 4 and string.sub(link,1,4) == "url:" then
pfUI.chat.urlcopy.CopyText(string.sub(link,5, string.len(link)))
end
return
end
pfUI.chat.urlcopy.SetItemRef(link, text, button)
end
pfUI.chat.right = CreateFrame("Frame", "pfChatRight", UIParent)
pfUI.chat.right:SetFrameStrata("BACKGROUND")
pfUI.chat.right:SetWidth(C.chat.right.width)
+3 -3
View File
@@ -1399,7 +1399,7 @@ pfUI:RegisterModule("gui", function ()
donate:SetHeight(20)
donate:SetText(T["Donate"])
donate:SetScript("OnClick", function()
pfUI.chat.urlcopy.CopyText("https://buymeacoffee.com/brues")
CopyText("https://buymeacoffee.com/brues")
end)
SkinButton(donate)
@@ -1409,7 +1409,7 @@ pfUI:RegisterModule("gui", function ()
github:SetHeight(20)
github:SetText(T["GitHub"])
github:SetScript("OnClick", function()
pfUI.chat.urlcopy.CopyText(GetAddOnMetadata(pfUI.name, "X-Website"))
CopyText(GetAddOnMetadata(pfUI.name, "X-Website"))
end)
SkinButton(github)
@@ -1419,7 +1419,7 @@ pfUI:RegisterModule("gui", function ()
website:SetHeight(20)
website:SetText(T["Website"])
website:SetScript("OnClick", function()
pfUI.chat.urlcopy.CopyText(GetAddOnMetadata(pfUI.name, "X-Website"))
CopyText(GetAddOnMetadata(pfUI.name, "X-Website"))
end)
SkinButton(website)
end)
+1
View File
@@ -370,6 +370,7 @@ pfUI:RegisterModule("share", function ()
local encoded = Encode(DiffConfig(myconfig, defconfig, ignored) or {})
f.scroll:SetText(encoded)
CopyText(encoded)
end)
end