View Single Post
07-16-20, 12:05 PM   #7
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 320
For CharcterFrame you can simply do:
Code:
hooksecurefunc(CharcterFrame, "Show", function() print("Showing CharcterFrame") end)
hooksecurefunc(CharcterFrame, "Hide", function() print("Hiding CharcterFrame") end)

But for PlayerTalentFrame (and others like ArchaeologyFrame, InspectFrame, AuctionHouseFrame, ClassTrainerFrame) it is a bit more complicated, because these frames do not exist yet after login. You have to wait with your hook until after they are created, and that is what these events you are mentioning can be helpful for. So for PlayerTalentFrame you could do:
Code:
local playerTalentFrameHooked = false
local addonLoadedFrame = CreateFrame("Frame")
addonLoadedFrame:RegisterEvent("ADDON_LOADED")
addonLoadedFrame:SetScript("OnEvent", function(self, event, arg1, ...)
  if not playerTalentFrameHooked and arg1 == "Blizzard_TalentUI" then
    hooksecurefunc(PlayerTalentFrame, "Show", function() print("Showing PlayerTalentFrame") end)
    hooksecurefunc(PlayerTalentFrame, "Hide", function() print("Hiding PlayerTalentFrame") end)
    playerTalentFrameHooked = true
  end
end)
__________________
~ Be the change you want to see in the world... of warcraft interface! ~
  Reply With Quote