View Single Post
02-07-12, 01:48 PM   #2
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 124
Your script is good, it's Recount that's causing your problem. It seems to have a mind of it's own when it comes to showing and hiding.

You can parent the Recount panel to your kgPanels panel though and use the following code:


OnLoad
Lua Code:
  1. self:RegisterEvent("PARTY_MEMBERS_CHANGED")
  2. self:RegisterEvent("RAID_ROSTER_UPDATE")
  3. Recount_MainWindow:SetParent(self)

OnEvent
Lua Code:
  1. local pmems = GetNumPartyMembers()
  2. local rmems = GetNumRaidMembers()
  3. if (pmems < 1 and rmems < 1) then -- you're neither in a party or a raid
  4.   self:Hide()
  5. elseif (pmems >= 1 or rmems >= 1) then -- it knows it needs to do something
  6.   self:Show() -- you're panel (and Recount) shows
  7. end

That should work. Because you've told Recount to parent to your own panel at OnLoad, it can only show when your panel does, so you should be in a position where you just need to tell your panel what to do.

While I'm at it, you can add this to OnLoad too to ensure that your panel always re-sizes correctly whenever Recount_MainWindow's size changes.

Ordinarily, anchoring your frame to 2 opposing corners of another frame at OnLoad should ensure that your frame and the other frame remain the same size regardless, but that doesn't seem to be the case with kgPanels. Hence, the following is required (untested):

OnLoad
Lua Code:
  1. Recount_MainWindow:HookScript("OnSizeChanged", function
  2.   self:ClearAllPoints()
  3.   self:SetPoint("TOPLEFT", Recount_MainWindow, "TOPLEFT", -2, 2)
  4.   self:SetPoint("BOTTOMRIGHT", Recount_MainWindow, "BOTTOMRIGHT", 2, -2)
  5. end)

Put Recount in the "Script Dependences" bit to prevent problems during OnLoad.

Hope this helped.
__________________
__________________

Last edited by Aanson : 07-22-12 at 04:01 AM. Reason: Removed code
  Reply With Quote