I have an options menu (invoked via minimap icon) with a fontstring that needs periodic updating. Specifically, this particular string shows an inventory bag’s count of free slots (Returned from C_Container.GetContainerNumFreeSlots()).
Here is the code that creates and initializes the fontstring that will later need updating.
bag.Caption = f:CreateFontString(nil, ARTWORK, GameFontNormal)
bag.Caption:SetJustifyH(LEFT)
bag.Caption:SetPoint(LEFT, bag.xPos + (BUTTON_WIDTH + 30), bag.yPos )
bag.Caption:SetFormattedText(%s: %d %s, bag.BagName, bag.NumFreeSlots, L[AVAILABLE_SLOTS] )
Now, when the bag’s count of free slots changes, I want to modify the fontstring to reflect an updated count of the bag’s free slots. The code that updates the fontstring resides in the event handlers for “BAG_UPDATE” and “BAG_UPDATE_DELAYED” are shown below. However, it doesn’t work because I cannot figure out how to erase/clear the previous text. I’ve tried variations of the code below, including just recreating the fontstring.
if bag.NumFreeSlots ~= newFreeSlotCount then
bag.NumFreeSlots = newFreeSlotCount
bag.Caption:SetFormattedText( "%s: %d %s", bag.BagName, bag.NumFreeSlots, L["AVAILABLE_SLOTS"] )
end
So, my question is this: how do I clear the previous text so that it doesn’t show through from under the new, updated text?
Thanks in advance,