Thread Tools Display Modes
01-12-16, 07:53 PM   #1
Iezabel
A Deviate Faerie Dragon
 
Iezabel's Avatar
Join Date: Oct 2014
Posts: 10
Chat Options

I know there are a ton of Chat Addons out there already. But I want to go ahead and create my own. So far things are working well with it but I am running into an issue. I want to have windows switch out based on if you are in a group or not. Is this possible or would the easiest way be to have buttons with the OnPush event to show/hide the windows?
  Reply With Quote
01-17-16, 07:02 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You can listen for GROUP_ROSTER_UPDATE events. Keep track of the group state in a variable outside of your event handler. When the group changes, figure out if your actual group state changed (the event fires for all kinds of group related reasons, not just joining/leaving one) and if it did, make the appropriate changes in your addon.

Code:
local inGroup

local frame = CreateFrame("Frame")
frame:RegisterEvent("GROUP_ROSTER_UPDATE")
frame:SetScript("OnEvent", function(self, event)
     local inGroupNow = IsInGroup()
     if inGroupNow == inGroup then return end -- nothing changed
     inGroup = inGroupNow -- store the new state
     -- make your changes here
end)
You can also get more detailed about tracking the group type/size (eg. to use different layouts in a raid group vs a battleground vs a 5-man, etc.). See Grid's code for an example.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Chat Options

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off