Figured I would bring this question to the more knowledgeable Lua programmers.
I hook the GameTooltip "OnTooltipSetItem" using GameTooltip:HookScript.
It works great, although after inserting a print command to see how often the passed function got called, Im ... puzzled. Basically whenever I mouse over an item in my inventory or bags, and remain mousing over it (for example to actually read the tooltip info lol) it keeps calling the script over and over again, until I stop mousing over.
Is this really how its supposed to be? It seems extraordinary inefficent, so I figured it might be me doing something wrong somewhere ><
That's intended. The "problem" is that the tooltip is set frequently to reflect cooldown numbers in the tooltip changing, even if the item has no cooldown, apparently. There might be other reasons why they set the tooltip constantly too, not sure. But you're doing it right.
Did you know the tooltip used to be set every frame? It took a while to get Blizzard to throttle their bag item buttons and char pane to only set the tooltip every 0.2 seconds (its a constant in one of their files).