Posted by theblade on Sat, 31 Oct 2009 16:17:58
Hey everyone. I have written an addon that listens for the guild achievement event and gchats a random "Congrats" message. It works great, except I wanted to add a UI to the addon to let people add their own messages to the table.
My problems is very simple though, I dont know how to make the contents of the table when added to the FontString on the frame, to stay in the frame. I have tried follow the wowwiki anchoring info (http://www.wowwiki.com/UIOBJECT_FontString) however, I'm just not able to comprehend it very well and really need to learn by example.
I've tried use setAllPoints and setHeight attributes with no luck. below is an example of my XML for my FontString
<FontString name="$parent_Text1" inherits="GameFontNormal" text="" justifyH="LEFT" setAllPoints="true" setHeight="250"> <Anchors> <Anchor point="TOPLEFT"> <Offset> <AbsDimension x="10" y="-10"/> </Offset> </Anchor> </Anchors> <Color r="0.8" g="0.5" b="0" a="1"/> </FontString>
and the lua populating this frames FontString is :
local function sag_LoadTable() local text = "" local oldtext = "" local pName = UnitName("player") for index,txt in pairs(gratsMsg) do oldtext = sagFrame_Text1:GetText(); if (oldtext) then txt = string.gsub(txt,"<playername>",pName) newtext = index ..": ".. txt -- newtext = strCrop(newtext); text = oldtext .."\n".. newtext sagFrame_Text1:SetText(text, 1.0, 1.0, 0, 1, 10); else txt = string.gsub(txt,"<playername>",pName) text = index ..": ".. txt -- text = strCrop(text); sagFrame_Text1:SetText(text, 1.0, 1.0, 0, 1, 10); end end end
You can see i'm using the for loop to cycle through the array of possible messages to display whats already being used.
So if someone can show me any example of how to make the text not go outside of the frame and actually make a functional scroll frame that would be spiffy
Posted by jnwhiteh on Sat, 31 Oct 2009 18:41:14
Well there's a lot going on here. What you're trying to do isn't really all that easy. You can have the font string clip the contents so it doesn't display outside the boundaries, or you can use a scroll frame.
The first thing I see is you're using setHeight as an XML attribute. That doesn't validate because its not correct. What you need instead is:
<Size x="width" y="height"/>
in the XML definition, with proper values for height and width. As for a scroll frame, you can read the chapter in the book on real scroll frames and it should be fairly obvious how to make this work.