Thursday, April 12, 2012

FontString:SetText(..) does nothing

[:1]So I try to use FontString:SetText(...) in my addon but nothing happends, the text does not change. I first figured it had to do with it not redrawing but doing a Hide() and then Show() doesn't solve the problem, and there is nothing like Invalidate or Refresh.

Is this a bug or should it just not be possible to have labels which dynamically change text?|||http://www.wowwiki.com/API_FontString_SetText

says

"The Font must be set before calling this function. This is not done for you if the FontString is created via Frame:CreateFontString. There are 3 ways to ensure the Font is set:

* Send in an inheritsFrom value to Frame:CreateFontString.

* Set the inheritsFrom via FontInstance:SetFontObject.

* Set the font directly via FontInstance:SetFont."|||Thanks for your reply, however I think I do that. The FontString is created in my xml file and looks like this:


Code:
<FontString name="PlayerName" inherits="ChatFontNormal" bytes="0" text="PlayerName">
<Size>
<AbsDimension x="80" y="20" />
</Size>
<Anchors>
<Anchor point="TOPLEFT">
<Offset x="26" y="-14" />
</Anchor>
</Anchors>
</FontString>

I simply assumed the inhertisFrom was set since I do inherits in the xml, but maybe that is not the case?|||I found the problem.. it was an issue of conflicting names, PlayerName was already taken and so PlayerName:SetText() did work, it just didn't change the text of the label I expected.

Namespaces would be helpful :)

No comments:

Post a Comment