Quantcast
WoWInterface - View Single Post - GameToolTip Update Event
View Single Post
01-19-21, 03:48 AM   #1
Tranzalore
A Murloc Raider
Join Date: Jan 2021
Posts: 6
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)
If i Comment out the last line the normal GameToolTip works again. Any idea on how i can get the GameTooltip OnUpdate script to trigger stuff in my addonwithout breaking the normal functionality.

Any help would be apreciated.
  Reply With Quote