mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-31 16:06:57 +00:00
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:
@@ -579,6 +579,14 @@ function pfUI.api.SendChatMessageWide(msg)
|
|||||||
SendChatMessage(msg,channel)
|
SendChatMessage(msg,channel)
|
||||||
end
|
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 ]
|
-- [ GroupInfoByName ]
|
||||||
-- Gets the unit id by name
|
-- Gets the unit id by name
|
||||||
-- 'name' [string] party or raid member
|
-- 'name' [string] party or raid member
|
||||||
|
|||||||
Vendored
+1
@@ -161,6 +161,7 @@ pfUI_translation["deDE"] = {
|
|||||||
["Cooldown Text Time Threshold"] = nil,
|
["Cooldown Text Time Threshold"] = nil,
|
||||||
["Coordinates Location"] = nil,
|
["Coordinates Location"] = nil,
|
||||||
["Coordinates On Minimap"] = nil,
|
["Coordinates On Minimap"] = nil,
|
||||||
|
["Copied to clipboard"] = nil,
|
||||||
["Count"] = nil,
|
["Count"] = nil,
|
||||||
["Create Profile"] = nil,
|
["Create Profile"] = nil,
|
||||||
["Ctrl-Click"] = nil,
|
["Ctrl-Click"] = nil,
|
||||||
|
|||||||
Vendored
+1
@@ -167,6 +167,7 @@ pfUI_translation["enUS"] = {
|
|||||||
["Cooldown Text Time Threshold"] = nil,
|
["Cooldown Text Time Threshold"] = nil,
|
||||||
["Coordinates Location"] = nil,
|
["Coordinates Location"] = nil,
|
||||||
["Coordinates On Minimap"] = nil,
|
["Coordinates On Minimap"] = nil,
|
||||||
|
["Copied to clipboard"] = nil,
|
||||||
["Count"] = nil,
|
["Count"] = nil,
|
||||||
["Create Profile"] = nil,
|
["Create Profile"] = nil,
|
||||||
["Ctrl-Click"] = nil,
|
["Ctrl-Click"] = nil,
|
||||||
|
|||||||
Vendored
+1
@@ -161,6 +161,7 @@ pfUI_translation["esES"] = {
|
|||||||
["Cooldown Text Time Threshold"] = "Umbral del texto del tiempo de reutilización",
|
["Cooldown Text Time Threshold"] = "Umbral del texto del tiempo de reutilización",
|
||||||
["Coordinates Location"] = "Coordenadas de localización",
|
["Coordinates Location"] = "Coordenadas de localización",
|
||||||
["Coordinates On Minimap"] = "Coordenadas en el minimapa",
|
["Coordinates On Minimap"] = "Coordenadas en el minimapa",
|
||||||
|
["Copied to clipboard"] = nil,
|
||||||
["Count"] = "Recuento",
|
["Count"] = "Recuento",
|
||||||
["Create Profile"] = "Crear perfil",
|
["Create Profile"] = "Crear perfil",
|
||||||
["Ctrl-Click"] = "Ctrl-Clic",
|
["Ctrl-Click"] = "Ctrl-Clic",
|
||||||
|
|||||||
Vendored
+1
@@ -161,6 +161,7 @@ pfUI_translation["frFR"] = {
|
|||||||
["Cooldown Text Time Threshold"] = "Seuil du texte des temps de recharge",
|
["Cooldown Text Time Threshold"] = "Seuil du texte des temps de recharge",
|
||||||
["Coordinates Location"] = "Coordonnées Emplacement",
|
["Coordinates Location"] = "Coordonnées Emplacement",
|
||||||
["Coordinates On Minimap"] = "Coordonnées sur la mini-carte",
|
["Coordinates On Minimap"] = "Coordonnées sur la mini-carte",
|
||||||
|
["Copied to clipboard"] = nil,
|
||||||
["Count"] = "Compter",
|
["Count"] = "Compter",
|
||||||
["Create Profile"] = "Créer un profil",
|
["Create Profile"] = "Créer un profil",
|
||||||
["Ctrl-Click"] = "Ctrl-Clique",
|
["Ctrl-Click"] = "Ctrl-Clique",
|
||||||
|
|||||||
Vendored
+1
@@ -161,6 +161,7 @@ pfUI_translation["koKR"] = {
|
|||||||
["Cooldown Text Time Threshold"] = "재사용 대기시간 텍스트 임계 값",
|
["Cooldown Text Time Threshold"] = "재사용 대기시간 텍스트 임계 값",
|
||||||
["Coordinates Location"] = nil,
|
["Coordinates Location"] = nil,
|
||||||
["Coordinates On Minimap"] = "미니맵의 좌표",
|
["Coordinates On Minimap"] = "미니맵의 좌표",
|
||||||
|
["Copied to clipboard"] = nil,
|
||||||
["Count"] = "카운트",
|
["Count"] = "카운트",
|
||||||
["Create Profile"] = "프로파일 생성",
|
["Create Profile"] = "프로파일 생성",
|
||||||
["Ctrl-Click"] = nil,
|
["Ctrl-Click"] = nil,
|
||||||
|
|||||||
Vendored
+1
@@ -161,6 +161,7 @@ pfUI_translation["ruRU"] = {
|
|||||||
["Cooldown Text Time Threshold"] = "Порог текста восстановления",
|
["Cooldown Text Time Threshold"] = "Порог текста восстановления",
|
||||||
["Coordinates Location"] = "Расположение координат",
|
["Coordinates Location"] = "Расположение координат",
|
||||||
["Coordinates On Minimap"] = "Координаты на миникарте",
|
["Coordinates On Minimap"] = "Координаты на миникарте",
|
||||||
|
["Copied to clipboard"] = nil,
|
||||||
["Count"] = "Счет",
|
["Count"] = "Счет",
|
||||||
["Create Profile"] = "Создать профиль",
|
["Create Profile"] = "Создать профиль",
|
||||||
["Ctrl-Click"] = "Ctrl+нажатие",
|
["Ctrl-Click"] = "Ctrl+нажатие",
|
||||||
|
|||||||
Vendored
+1
@@ -161,6 +161,7 @@ pfUI_translation["zhCN"] = {
|
|||||||
["Cooldown Text Time Threshold"] = "技能冷却时间文字临界值",
|
["Cooldown Text Time Threshold"] = "技能冷却时间文字临界值",
|
||||||
["Coordinates Location"] = "坐标位置",
|
["Coordinates Location"] = "坐标位置",
|
||||||
["Coordinates On Minimap"] = "小地图上的坐标",
|
["Coordinates On Minimap"] = "小地图上的坐标",
|
||||||
|
["Copied to clipboard"] = nil,
|
||||||
["Count"] = "计数器",
|
["Count"] = "计数器",
|
||||||
["Create Profile"] = "新建配置",
|
["Create Profile"] = "新建配置",
|
||||||
["Ctrl-Click"] = "CTRL点击",
|
["Ctrl-Click"] = "CTRL点击",
|
||||||
|
|||||||
Vendored
+1
@@ -161,6 +161,7 @@ pfUI_translation["zhTW"] = {
|
|||||||
["Cooldown Text Time Threshold"] = "技能冷卻時間文字臨界值",
|
["Cooldown Text Time Threshold"] = "技能冷卻時間文字臨界值",
|
||||||
["Coordinates Location"] = "座標位置",
|
["Coordinates Location"] = "座標位置",
|
||||||
["Coordinates On Minimap"] = "小地圖上的座標",
|
["Coordinates On Minimap"] = "小地圖上的座標",
|
||||||
|
["Copied to clipboard"] = nil,
|
||||||
["Count"] = "計數器",
|
["Count"] = "計數器",
|
||||||
["Create Profile"] = "新建配置",
|
["Create Profile"] = "新建配置",
|
||||||
["Ctrl-Click"] = "CTRL點擊",
|
["Ctrl-Click"] = "CTRL點擊",
|
||||||
|
|||||||
+4
-67
@@ -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"] = 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)
|
function pfUI.chat:FormatLink(formatter,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
||||||
if not (formatter and a1) then return end
|
if not (formatter and a1) then return end
|
||||||
local newtext = string.format(formatter,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
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
|
return text
|
||||||
end
|
end
|
||||||
|
|
||||||
pfUI.chat.urlcopy = CreateFrame("Frame", "pfURLCopy", UIParent)
|
-- clicking a url link copies it
|
||||||
pfUI.chat.urlcopy:Hide()
|
LinkUtil.RegisterLinkHandler("url", function(link, text, linkData)
|
||||||
pfUI.chat.urlcopy:SetWidth(270)
|
CopyText(linkData.options)
|
||||||
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()
|
|
||||||
end)
|
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 = CreateFrame("Frame", "pfChatRight", UIParent)
|
||||||
pfUI.chat.right:SetFrameStrata("BACKGROUND")
|
pfUI.chat.right:SetFrameStrata("BACKGROUND")
|
||||||
pfUI.chat.right:SetWidth(C.chat.right.width)
|
pfUI.chat.right:SetWidth(C.chat.right.width)
|
||||||
|
|||||||
+3
-3
@@ -1399,7 +1399,7 @@ pfUI:RegisterModule("gui", function ()
|
|||||||
donate:SetHeight(20)
|
donate:SetHeight(20)
|
||||||
donate:SetText(T["Donate"])
|
donate:SetText(T["Donate"])
|
||||||
donate:SetScript("OnClick", function()
|
donate:SetScript("OnClick", function()
|
||||||
pfUI.chat.urlcopy.CopyText("https://buymeacoffee.com/brues")
|
CopyText("https://buymeacoffee.com/brues")
|
||||||
end)
|
end)
|
||||||
SkinButton(donate)
|
SkinButton(donate)
|
||||||
|
|
||||||
@@ -1409,7 +1409,7 @@ pfUI:RegisterModule("gui", function ()
|
|||||||
github:SetHeight(20)
|
github:SetHeight(20)
|
||||||
github:SetText(T["GitHub"])
|
github:SetText(T["GitHub"])
|
||||||
github:SetScript("OnClick", function()
|
github:SetScript("OnClick", function()
|
||||||
pfUI.chat.urlcopy.CopyText(GetAddOnMetadata(pfUI.name, "X-Website"))
|
CopyText(GetAddOnMetadata(pfUI.name, "X-Website"))
|
||||||
end)
|
end)
|
||||||
SkinButton(github)
|
SkinButton(github)
|
||||||
|
|
||||||
@@ -1419,7 +1419,7 @@ pfUI:RegisterModule("gui", function ()
|
|||||||
website:SetHeight(20)
|
website:SetHeight(20)
|
||||||
website:SetText(T["Website"])
|
website:SetText(T["Website"])
|
||||||
website:SetScript("OnClick", function()
|
website:SetScript("OnClick", function()
|
||||||
pfUI.chat.urlcopy.CopyText(GetAddOnMetadata(pfUI.name, "X-Website"))
|
CopyText(GetAddOnMetadata(pfUI.name, "X-Website"))
|
||||||
end)
|
end)
|
||||||
SkinButton(website)
|
SkinButton(website)
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -370,6 +370,7 @@ pfUI:RegisterModule("share", function ()
|
|||||||
|
|
||||||
local encoded = Encode(DiffConfig(myconfig, defconfig, ignored) or {})
|
local encoded = Encode(DiffConfig(myconfig, defconfig, ignored) or {})
|
||||||
f.scroll:SetText(encoded)
|
f.scroll:SetText(encoded)
|
||||||
|
CopyText(encoded)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user