-
Posted by thefuzzy0ne on Mon, 21 Mar 2011 18:03:45
Hi!
I'm currently creating an addon which will provide extra information as a tooltip when certain items are hovered over (be it in the user's inventory, bank, guild bank, vendors and so on).
There's a good chance that the tooltip may contain at least 10 lines, and since there are addons such as Altoholic which add information to the default tooltip, and others which add another tooltip, such as Auctioneer, which can often be quite lengthy, I've chosen to anchor my tooltip to the side of the default game tooltip.
To show the tooltip, I have hooked it in my initialisation function like so:
ContainerFrameItemButton_OnEnter_Old = ContainerFrameItemButton_OnEnter ContainerFrameItemButton_OnEnter = ContainerFrameItemButton_OnEnter_Hook
This works exactly as expected, but I'm having a problem hiding the tooltip when the cursor leaves the frame/button.
Blizzard haven't provided a function for me to hook, and I'm not sure how to do it, since I don't believe I can hook events on a predefined template.
I know there's a way to do it, since Auctioneer does it, but I'm getting completely lost in the code when I try to find out how they do it.
I'd appreciate any input that might help me get back on track, as I've been at this for hours now, and I haven't got anywhere. I suspect there's a really simple solution that I've completely overlooked.
Best wishes, and many thanks in advance.
-
Posted by jnwhiteh on Mon, 21 Mar 2011 18:19:56
Normally this is not done with hooking functions, but rather using and hooking the tooltip scripts themselves.
-
Posted by thefuzzy0ne on Mon, 21 Mar 2011 19:19:52
That's just what I was after. I knew there was a simple solution!
Many thanks. :)
-
Posted by thefuzzy0ne on Tue, 22 Mar 2011 11:03:35
Sorry, Jim. I'm still having trouble.
The events you mentioned hook just fine, however, both the OnTooltipSetItem and OnTooltipCleared events seem to fire once every half a second or so, for as long as you keep your cursor over an item button. I'm not quite sure why this is happening. Is this normal? Perhaps I should cache my own tooltips for this reason?
-
Posted by jnwhiteh on Tue, 22 Mar 2011 15:11:38
Sorry, Jim. I'm still having trouble.
The events you mentioned hook just fine, however, both the OnTooltipSetItem and OnTooltipCleared events seem to fire once every half a second or so, for as long as you keep your cursor over an item button. I'm not quite sure why this is happening. Is this normal? Perhaps I should cache my own tooltips for this reason?
Yes, they're firing like that because items can have cooldowns and other states, and these need to be polled.. there's no event for them. It's normal, but it shouldn't be a problem if you're just adding information to the tooltip. It depends on your specific purpose.
If you'd like, you can do it half-way, hook the container function (but your addon would not work for custom inventory/container addons) for when the tooltip is shown, and then hook the OnHide event of the tooltip that's been shown to hide or de-parent your tooltip.