View Single Post
03-25-13, 11:37 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Enumerating regions is not really ideal... not only will it give you things that aren't fontstrings, but it'll give you all the fontstrings in the tooltip, even the ones that aren't in use. Here's a better way:

Code:
for i = 1, MyScanningTooltip:NumLines() do
    local left = _G["MyScanningTooltipTextLeft"..i]
    local text = left:GetText()
    if text and text ~= "" then
        -- do something with the text
    end
end
Also, when using the SetX methods (SetBagItem, SetItem, SetSpell, etc.) it's not necessary to use ClearLines; that happens automatically. The only reason to use ClearLines is to redraw the contents of an open tooltip without reopening it, and I can't really think of any good use-cases for doing that either.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote