Quantcast
Copy From Chat Problem. - WoWInterface
Thread Tools Display Modes
12-09-16, 04:40 AM   #1
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Copy From Chat Problem.

Hey guys, since 7.1 my Copy From Chat hasn't worked not really sure what's wrong i've tried a lot of stuff, hope someone can help me

Lua Code:
  1. local CopyFrame = CreateFrame("Frame", nil, UIParent)
  2. CopyFrame:SetSize(600, 250)
  3. CopyFrame:SetPoint("CENTER", UIParent, 0, 0)
  4. CopyFrame:SetFrameStrata("DIALOG")
  5. CopyFrame:Hide()
  6.  
  7. CopyFrame:SetBackdrop({
  8.             edgeFile = "Interface\\Buttons\\WHITE8x8", edgeSize = 2,
  9.         })
  10. CopyFrame:SetBackdrop(0.050, 0.050, 0.050, 0.80)
  11.  
  12. local CopyEditBox = CreateFrame("EditBox", nil, CopyFrame)
  13. CopyEditBox:SetSize(600, 250)
  14.  
  15. CopyEditBox:SetMultiLine(true)
  16. CopyEditBox:SetMaxLetters(99999)
  17. CopyEditBox:EnableMouse(true)
  18. CopyEditBox:SetAutoFocus(false)
  19.  
  20. CopyEditBox:SetFont('Fonts\\ARIALN.ttf', 12, "THINOUTLINE")
  21. CopyEditBox:SetShadowOffset(1, -1)
  22. CopyEditBox:SetShadowColor(0,0,0)
  23.  
  24. CopyEditBox:SetScript("OnEscapePressed", function() CopyFrame:Hide() end)
  25.  
  26. --local CopyCloseButton = CreateFrame("Button", nil, CopyFrame, "UIPanelCloseButton")
  27.  
  28. local ScrollArea = CreateFrame("ScrollFrame", "ACopyScrollArea", CopyFrame, "UIPanelScrollFrameTemplate")
  29. ScrollArea:SetPoint("TOPLEFT", CopyFrame, "TOPLEFT", 8, -28)
  30. ScrollArea:SetPoint("BOTTOMRIGHT", CopyFrame, "BOTTOMRIGHT", -28, 8)
  31. ScrollArea:SetScrollChild(CopyEditBox)
  32.  
  33.  
  34. local Lines = {}
  35.  
  36. local function GetLines(...)
  37.     local Count = 1
  38.     for i = select("#", ...), 1, -1 do
  39.         local Region = select(i, ...)
  40.         if (Region:GetObjectType() == "FontString") then
  41.             Lines[Count] = tostring(Region:GetText())
  42.             Count = Count + 1
  43.         end
  44.     end
  45.     return Count - 1
  46. end
  47.  
  48. local function CopyText(self)
  49.     local LineCount = GetLines(self:GetRegions())
  50.     local Text = table.concat(Lines, "\n", 1, LineCount)
  51.    
  52.     if CopyFrame:IsVisible() then return CopyFrame:Hide() end
  53.  
  54.     CopyEditBox:SetText(Text)
  55.     CopyFrame:Show()
  56. end
  57.  
  58. for i = 1, NUM_CHAT_WINDOWS do
  59.     local Frame = _G["ChatFrame"..i]
  60.  
  61.     local Button = CreateFrame("Button", nil, Frame)
  62.     Button:SetSize(16, 16)
  63.     Button:SetPoint("TOPRIGHT", 0, 1.5)
  64.     Button:SetAlpha(0.25)
  65.    
  66.     local ButtonTexture = Button:CreateTexture(nil, "BORDER")
  67.     ButtonTexture:SetSize(22, 22)
  68.     ButtonTexture:SetPoint("CENTER", Button, 0.5, 0)
  69.     ButtonTexture:SetTexture("Interface\\Buttons\\WHITE8x8")
  70.     ButtonTexture:SetVertexColor(0.355, 0.355, 0.355)
  71.  
  72.     Button:SetScript("OnMouseUp", function(self) CopyText(self.ChatFrame) end)
  73.     Button:SetScript("OnEnter", function(self) UIFrameFadeIn(Button, 1, Button:GetAlpha(), 1) end)
  74.     Button:SetScript("OnLeave", function(self) UIFrameFadeIn(Button, 1, Button:GetAlpha(), 0.25) end)
  75.    
  76.     Button.ChatFrame = Frame
  77. end
  Reply With Quote
12-09-16, 05:42 AM   #2
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Hasn't worked how?
__________________
Grab your sword and fight the Horde!
  Reply With Quote
12-09-16, 07:20 AM   #3
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by Lombra View Post
Hasn't worked how?
It doesn't copy from the chat anymore and its just blank
  Reply With Quote
12-09-16, 07:34 AM   #4
Kkthnx
A Cobalt Mageweaver
 
Kkthnx's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2011
Posts: 247
You need to add

Lua Code:
  1. for i = 1, self:GetNumMessages() do
  2.     Text = Text..self:GetMessageInfo(i).."\n"
  3. end

So replace your "CopyText" function with.

Lua Code:
  1. local function CopyText(self)
  2.     local LineCount = GetLines(self:GetRegions())
  3.     local Text = table.concat(Lines, "\n", 1, LineCount)
  4.  
  5.     if CopyFrame:IsVisible() then return CopyFrame:Hide() end
  6.  
  7.     for i = 1, self:GetNumMessages() do
  8.         Text = Text..self:GetMessageInfo(i).."\n"
  9.     end
  10.  
  11.     CopyEditBox:SetText(Text)
  12.     CopyFrame:Show()
  13. end
__________________
Success isn't what you've done compared to others. Success is what you've done compared to what you were made to do.
  Reply With Quote
12-10-16, 09:55 AM   #5
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by Kkthnx View Post
You need to add

Lua Code:
  1. for i = 1, self:GetNumMessages() do
  2.     Text = Text..self:GetMessageInfo(i).."\n"
  3. end

So replace your "CopyText" function with.

Lua Code:
  1. local function CopyText(self)
  2.     local LineCount = GetLines(self:GetRegions())
  3.     local Text = table.concat(Lines, "\n", 1, LineCount)
  4.  
  5.     if CopyFrame:IsVisible() then return CopyFrame:Hide() end
  6.  
  7.     for i = 1, self:GetNumMessages() do
  8.         Text = Text..self:GetMessageInfo(i).."\n"
  9.     end
  10.  
  11.     CopyEditBox:SetText(Text)
  12.     CopyFrame:Show()
  13. end
Works perfectly, thank you!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Copy From Chat Problem.

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off