View Single Post
05-27-22, 04:04 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
You can't "programatically" send text to the clipboard. You need the frame to display the text that you then select and CTRL-C to get it onto the clipboard.

You can create a frame with an EditBox and automaticaly set it to select some text (EditBox:HighlightText(start, end)) so you just need to CTRL-C to copy to the clipboard.

Edit: I missed the bit where you were asking for a popup frame if that was the only way.

You can paste the following into the website addon.bool.no and give it a unique title (GetGold?) to create/download a small addon to do this. /gg will show/hide the frame with your current gold/silver/copper (the button will toggle current character/all characters) ready to copy (CTRL-C).Pasting the text into an editor will paste the numbers but not the icons.
Notes
Using a text editor (eg. NotPad):
The following line will need to be added (after the other lines starting with ##) to the addons .TOC file located in the addons folder (THE ADDON WILL NOT WORK PROPERLY WITHOUT THIS):
## SavedVariables: GG_DATA

Will only show total gold for characters you have logged on to.
Will show gold for deleted character unless you edit the addons SavedVariables file and delete the characters information:
File Location:
[WoW folder]\[game version folder eg. _retail_]\WFT\Account\[your account name]\SavedVariables\[addon name].lua
Lua Code:
  1. local f = CreateFrame("Frame", "GetGoldDisplayFrame", UIParent, BackdropTemplateMixin and "BackdropTemplate")
  2. f:SetPoint("CENTER")
  3. f:SetMovable(true)
  4. f:SetUserPlaced(true)
  5.  
  6. local CTData, CTName
  7.  
  8. f:RegisterEvent("PLAYER_LOGIN")
  9. f:RegisterEvent("PLAYER_MONEY")
  10. f:SetScript("OnEvent", function(self, event)
  11.     if event == "PLAYER_MONEY" then
  12.         CTData.gold = GetMoney()
  13.         return
  14.     end
  15.     GG_DATA = GG_DATA or { characters={} }
  16.     CTName = UnitName("player")
  17.     CTData = CTName .. "-" .. GetNormalizedRealmName()
  18.     if not GG_DATA.characters[CTData] then
  19.         GG_DATA.characters[CTData] = { }
  20.     end
  21.     CTData = GG_DATA.characters[CTData]
  22.     CTData.gold = GetMoney()
  23. end)
  24.  
  25. local TotalText = "Total Gold is:"
  26. local PlayerText = "Gold for %s:"
  27.  
  28. local function ShowGold(self, playergold)
  29.     local Total = 0
  30.     if not playergold then
  31.         self.Title:SetText(TotalText)
  32.         self.GetFor:SetText(CTName)
  33.         for k, v in pairs(GG_DATA.characters) do
  34.             Total = Total + v.gold
  35.         end
  36.     else
  37.         self.Title:SetText(format(PlayerText, CTName))
  38.         Total = CTData.gold
  39.         self.GetFor:SetText("All")
  40.     end
  41.     self.Text:SetText(GetMoneyString(Total, true))
  42.     self.Text:HighlightText()
  43.     self.Text:SetFocus()
  44.     self:Show()
  45. end
  46.  
  47. local function GetGold(msg)
  48.     if f.Title then
  49.         if f:IsShown() then
  50.             f:Hide()
  51.             return
  52.         end
  53.         ShowGold(f)
  54.         return
  55.     end
  56.     local backdrop = {
  57.         bgFile = "Interface/DialogFrame/UI-DialogBox-Background",
  58.         edgeFile = "Interface/GLUES/Common/Glue-Tooltip-Border",
  59.         tile = true,
  60.         edgeSize = 8,
  61.         tileSize = 8,
  62.         insets = {
  63.         left = 2,
  64.         right = 2,
  65.         top = 2,
  66.         bottom = 2,
  67.         },
  68.     }
  69.     f:EnableMouse(true)
  70.     f:RegisterForDrag("LeftButton")
  71.     f:SetClampedToScreen(true)
  72.     f:SetScript("OnDragStart", function(self) self:StartMoving() end)
  73.     f:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
  74.     f:SetBackdrop(backdrop)
  75.     f:SetSize(220, 100)
  76.     f.Title = f:CreateFontString()
  77.     f.Title:SetFontObject(GameFontNormal)
  78.     f.Title:SetPoint("TOP", 0, -5)
  79.     f.Title:SetText("Total Gold is:")
  80.     f.Close = CreateFrame("Button", "$parentClose", f, "UIPanelCloseButton")
  81.     f.Close:SetSize(24, 24)
  82.     f.Close:SetPoint("TOPRIGHT")
  83.     f.Text = CreateFrame("EditBox", nil, f)
  84.     f.Text:SetFontObject(GameFontNormal)
  85.     f.Text:SetSize(190, 24)
  86.     f.Text:SetJustifyH("CENTER")
  87.     f.Text:SetPoint("CENTER", 0, 10)
  88.     f.Text:SetMultiLine(false)
  89.     f.Text:SetScript("OnEscapePressed", function(self)
  90.         self:ClearFocus()
  91.         self:GetParent():Hide()
  92.     end)
  93.     f.GetFor = CreateFrame("Button", "$parentGetFor", f, "UIPanelButtonTemplate")
  94.     f.GetFor:SetSize(100, 30)
  95.     f.GetFor:SetText("All")
  96.     f.GetFor:SetPoint("BOTTOM", 0, 10)
  97.     f.GetFor:SetScript("OnClick", function(self)
  98.         self.Player = not self.Player
  99.         ShowGold(f, self.Player)
  100.     end)
  101.     ShowGold(f)
  102. end
  103.  
  104. SLASH_GG1 = "/gg"
  105. SlashCmdList.GG = GetGold
  106.  
  107. --[[    Notes
  108. -- Using a text editor (eg. NotPad):
  109. -- The following line will need to be added (after the other lines starting with ##) to the addons .TOC file located in the addons folder (THE ADDON WILL NOT WORK PROPERLY WITHOUT THIS):
  110. ## SavedVariables: GG_DATA
  111.  
  112. -- Will only show total gold for characters you have logged on to.
  113. -- Will show gold for deleted character unless you edit the addons SavedVariables file and delete the characters information:
  114. -- File Location:
  115. [WoW folder]\[game version folder eg. _retail_]\WFT\Account\[your account name]\SavedVariables\[addon name].lua
  116. ]]--
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 06-03-22 at 03:01 PM. Reason: Added popup frame code extras
  Reply With Quote