View Single Post
06-05-09, 05:03 PM   #23
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
This is easier to just write out than to explain. There are lots of other ways that you could do this as well, this is probably the simplest.
If MyFrame is the frame that you want the text to display in, then...

Code:
MyFrame.OnShow(self, ...)
   if self.MyFontStrings  then
      wipe(MyFontStrings)
   end

   self.MyFontStrings = {}
end
-------------------
MyFrame.EventHandler(self, event, ...)
    if event == "CHAT_MSG_ADDON" then
       local prefix, msg, type, sender = ...

       if prefix ~= "MyAddon_Reply" then return end

       local fontString = self:CreateFontString(nil,"OVERLAY")
       local anchorTo = (#self.MyFontStrings > 0) and self.MyFontStrings[#self.MyFontStrings] or self -- anchor to the last fontstring or to the parent frame if none
       self.MyFontStrings[#self.MyFontStrings + 1] = fontString
       fontString:ClearAllPoints()
       fontString:SetPoint("TOPLEFT", anchorTo, "TOPLEFT", 0, -5)
   
       fontString:SetText(("%s replied with %s."):Format(sender, msg))
    end
end
  Reply With Quote