Go to Page... |
Thread Tools | Display Modes |
01-19-21, 03:48 AM | #1 |
GameToolTip Update Event
I am creating an addon to automatically switch to your gathering skill set when you mouse over a node. The addon is currently getting its information from the GameToolTip.
I could not find any event linked to changes in theGameToolTip so I overrode the OnShow, OnHide and OnUpdate scripts. This works for my addon but it has broken any dynamic GameToolTips that updat when you hold down the shift modifier (eg show the item that you have equiped in the same slot at the item you are mousing over or with TSM when if updates the GameToolTip to show the prices for a stack instead of a single item. Code:
-- CreateEvent when GameToolTip Shows local function ToolTipOnShow() if (inDebugMode) then DEFAULT_CHAT_FRAME:AddMessage("Tooltip OnShow Event fired!") end GameTooltipLine1 = GameTooltipTextLeft1:GetText() GameTooltipLine2 = GameTooltipTextLeft2:GetText() GameTooltipLine3 = GameTooltipTextLeft3:GetText() GameTooltipChangeHandler() end GameTooltip:SetScript("OnShow", ToolTipOnShow) -- CreateEvent when GameToolTip Hides local function ToolTipOnHide() if (inDebugMode) then DEFAULT_CHAT_FRAME:AddMessage("Tooltip OnHide Event fired!") end GameTooltipLine1 = GameTooltipTextLeft1:GetText() GameTooltipLine2 = GameTooltipTextLeft2:GetText() GameTooltipLine3 = GameTooltipTextLeft3:GetText() GameTooltipChangeHandler() end GameTooltip:SetScript("OnHide", ToolTipOnHide) -- CreateEvent when GameToolTip Update local function ToolTipOnUpdate() if not (GameTooltipLine1 == GameTooltipTextLeft1:GetText() and GameTooltipLine2 == GameTooltipTextLeft2:GetText() and GameTooltipLine3 == GameTooltipTextLeft3:GetText()) then if (inDebugMode) then DEFAULT_CHAT_FRAME:AddMessage("Tooltip OnUpdate Event fired!") end GameTooltipLine1 = GameTooltipTextLeft1:GetText() GameTooltipLine2 = GameTooltipTextLeft2:GetText() GameTooltipLine3 = GameTooltipTextLeft3:GetText() GameTooltipChangeHandler() end end GameTooltip:SetScript("OnUpdate", ToolTipOnUpdate) Any help would be apreciated. |
|
01-19-21, 04:51 AM | #2 |
Why don't you hook the scripts instead of overriding them?
__________________
~ Be the change you want to see in the world... of warcraft interface! ~ |
|
01-19-21, 04:20 PM | #3 | ||
Thank you for the response LudiusMaximus.
I had tried to hook it instead of override but keept running into errors. When trying to do this I found this forum post and was basing my code off it. https://forum.elysium-project.org/to...tooltip-event/ So I tried...
" Interface\AddOns\ClassicAutoGearChanger\main.lua:334: attempt to call upvalue 'BlizzardGameTooltipOnUpdateRetention' (a nil value) Time: Wed Jan 20 09:11:12 2021 Count: 1765 Stack: Interface\AddOns\ClassicAutoGearChanger\main.lua:334: attempt to call upvalue 'BlizzardGameTooltipOnUpdateRetention' (a nil value) [C]: ? Interface\AddOns\ClassicAutoGearChanger\main.lua:334: in function <Interface\AddOns\ClassicAutoGearChanger\main.lua:332> [C]: ? [C]: ? Locals: " This makes me think that GameTooltip.OnUpdate does not exist but if it did not exist overriding it should not cause any issues so I am a bit lost. |
|||
01-19-21, 04:32 PM | #4 |
Just fount this on https://wowwiki.fandom.com/wiki/UIOBJECT_GameTooltip
"When you mouse over things in the game world, the game engine internally calls the equivalent of :Set____() - not the actual Lua method. In particular, this means that hooked GameTooltip methods will never trigger for engine-generated tooltips. Hooks will however catch all other tooltips generated from the UI itself. For non-item/unit tooltips you will even see :AddLine and :AddDoubleLine calls." Does this mean that I need to hook the AddLine and AddDoubleLine scripts instead? |
|
01-19-21, 06:16 PM | #5 |
Instead of
Code:
local BlizzardGameTooltipOnUpdateRetention = GameTooltip.OnUpdate Code:
local BlizzardGameTooltipOnUpdateRetention = GameTooltip:GetScript("OnUpdate") Is it important that your CustomToolTipOnUpdate() gets called before BlizzardGameTooltipOnUpdateRetention()? If not, just do a HookScript: Lua Code:
__________________
~ Be the change you want to see in the world... of warcraft interface! ~ |
|
01-20-21, 03:25 PM | #6 | ||
Thank you again for your response. It was very helpful.
To start with I changed the code to the following and got things to work.
Again thanks alot for you assistance I really apreciated it. |
|||
WoWInterface » Classic - AddOns, Compliations, Macros » Classic - AddOn Help/Support » GameToolTip Update Event |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|