1. Currently hacking together my first addon and I have been trying to get a window i create to :Show() or :Hide() but i can not seem to find a correct event to hook into. I am specifically looking to show this window when the Pet Journal inside of the collections window is active, and :Hide() when the Pet Journal is closed or another tab inside of the Collections window is activated.

    I was trying to see how the authors of PetBattleTeams addon did this but I am having difficulties following their code design. I'm sure it's well written, I just get lost when design patterns are thrown in which, I believe they are using.

    Anyways here is some spaghetti code I've managed to hack together, which I'll admit does display the empty frame when the Pet Journal is first opened. I feel is a much more elegant solution for this. Also, I noticed the "PETJOURNALLIST_UPDATE" event doesn't get fired after the first time it's opened, and I can't find out which event is called when the Collections window is closed. I've scoured through wowprogramming and wowwiki and wowpedia looking for events for this but am not finding anything promissing. I know it's possible seeing as there is tons of addons that do this exact action.

    Thanks for the help in advance!

    local shown = false
    local function OnEvent(self,event,...)
      local name = ...
      name = name or "N/A"
      print("Event: "..event.."     ".."Name: "..name)
      if(IsAddOnLoaded("Blizzard_Collections") or name == "Blizzard_Collections") then
        if not mainFrame then
          mainFrame = CreateMainFrame()
        if shown then
          shown = false
        if not shown then
          shown = true
    local eventFrame = CreateFrame("frame")
    eventFrame:SetScript("OnEvent", OnEvent)