
HideTooltip Function Interferes with Tooltip Display in Other Addons
Kkthnx opened this issue ยท 6 comments
Description
The HideTooltip
function in Core.lua
unhooks the previous OnShow
script and hooks a new one, causing issues with the tooltip display in other addons. This interference can lead to tooltips not showing correctly. This causes issues in my 2 UIs KkthnxUI and NexEnhance. If you have a better approach let me know.
https://github.com/Kkthnx-Wow/NexEnhance
https://github.com/Kkthnx-Wow/KkthnxUI
basically, will break my tooltips and they won't be displayed correctly. Main issue is the skinning to the status bar doesn't show correctly or at all...
Problematic Code
local function HideTooltip(shouldHide)
local hookFunction = function()
if shouldHide then
_G.GameTooltip:Hide()
else
_G.GameTooltip:Show()
end
end
-- Need to call it immediately in case there's a tooltip still fading
hookFunction()
_G.GameTooltip:SetScript("OnShow", nil) -- unhook previous script
_G.GameTooltip:HookScript("OnShow", hookFunction)
end
Suggested Code
local tooltipHidden = false
local function HideTooltip(shouldHide)
tooltipHidden = shouldHide
local hookFunction = function()
if tooltipHidden then
_G.GameTooltip:Hide()
end
end
-- Need to call it immediately in case there's a tooltip still fading
hookFunction()
_G.GameTooltip:HookScript("OnShow", function(self)
if tooltipHidden then
self:Hide()
end
end)
end
If you want example, please let me know I can provide, and we can come up with a solution. Thank you for making such an amazing addon <3
Sorry it took me this long to respond, @Kkthnx. I've been busy playing PoE 2 for the past few weeks and haven't paid much attention to the addon other than answering questions on Discord. I'll push an update soon with the suggested change. Thank you!
Gotta figure out another approach. Not unhooking previous scripts from the tooltip is causing an overflow bug.
But doing this _G.GameTooltip:SetScript("OnShow", nil)
to unhook them before hooking a new script is what's causing issues with your UI.
5x C stack overflow
[string "=[C]"]: ?
[string "=[C]"]: ?
[string "=[C]"]: in function SetParent'
[string "@oUF_KarUI/embeds/oUF/blizzard.lua"]:26: in function <oUF_KarUI/embeds/oUF/blizzard.lua:24>
[string "=[C]"]: in function SetParent'
[string "@ls_UI/embeds/oUF/blizzard.lua"]:26: in function <ls_UI/embeds/oUF/blizzard.lua:24>
[string "=[C]"]: ?
[string "=[C]"]: in function SetParent'
[string "@oUF_KarUI/embeds/oUF/blizzard.lua"]:26: in function <oUF_KarUI/embeds/oUF/blizzard.lua:24>
[string "=[C]"]: in function SetParent'
[string "@ls_UI/embeds/oUF/blizzard.lua"]:26: in function <ls_UI/embeds/oUF/blizzard.lua:24>
[string "=[C]"]: ?
...
[string "=[C]"]: in function SetParent'
[string "@Blizzard_EditMode/Mainline/EditModeSystemTemplates.lua"]:311: in function BreakFromFrameManager'
[string "@Blizzard_EditMode/Mainline/EditModeSystemTemplates.lua"]:332: in function ApplySystemAnchor'
[string "@Blizzard_EditMode/Mainline/EditModeSystemTemplates.lua"]:364: in function UpdateSystem'
[string "@Blizzard_EditMode/Mainline/EditModeManager.lua"]:1204: in function UpdateSystem'
[string "@Blizzard_EditMode/Mainline/EditModeManager.lua"]:1192: in function <...ddOns/Blizzard_EditMode/Mainline/EditModeManager.lua:1191>
[string "=[C]"]: in function secureexecuterange'
[string "@Blizzard_EditMode/Mainline/EditModeManager.lua"]:1194: in function UpdateSystems'
[string "@Blizzard_EditMode/Mainline/EditModeManager.lua"]:864: in function UpdateLayoutInfo'
[string "@Blizzard_EditMode/Mainline/EditModeManager.lua"]:155: in function <...ddOns/Blizzard_EditMode/Mainline/EditModeManager.lua:152>
Locals:
(*temporary) = "C stack overflow"
(*temporary) = "C stack overflow"
Adding a flag to prevent duplicate hooks should do the trick. That way we don't have to clear anything. Something like this:
local tooltipHidden = false
local isTooltipHooked = false
local function HideTooltip(shouldHide)
tooltipHidden = shouldHide
if not isTooltipHooked then
GameTooltip:HookScript("OnShow", function(self)
if tooltipHidden then
self:Hide()
end
end)
isTooltipHooked = true
end
if tooltipHidden and GameTooltip:IsShown() then
GameTooltip:Hide()
end
end
Resolved with #149