Quantcast Cycle through tabs in a chat window - WoWInterface
Thread Tools Display Modes
11-04-18, 11:33 PM   #1
myrroddin
A Molten Giant
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 944
Cycle through tabs in a chat window

Is there a way to programmatically cycle through the chat tabs in a chatframe? For example, in my ChatFrame1, I have General, Log, Guild, but what if you don't know how many tabs a user has, or what the tab names are?

I've gone through the FrameXML to look for clues, but so far haven't found anything.

EDIT: I don't need the tab names per se. Rather, I am trying to clear all the text in each tab of each chatframe.
Lua Code:
  1. for i = 1, NUM_CHAT_WINDOWS do
  2.     local window = _G["ChatFrame"..i]
  3.     window:Clear() -- this clears the first window in ChatFrame1, ChatFrame2, etc
  4.     -- great, now get the next tab, but how?
  5. end

Last edited by myrroddin : 11-05-18 at 12:25 AM.
  Reply With Quote
11-05-18, 03:50 AM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,252
The code you have should clear all the main frames including the combat log ( ChatFrame2 ).

For the temporary chat frames to get included this may be a better option.


FCFDock_GetChatFrames(dock) to receive a list of windows that are docked

DOCKED_CHAT_FRAMES is the table containing the docked chat frames.

So,

GENERAL_CHAT_DOCK.DOCKED_CHAT_FRAMES or
FCFDock_GetChatFrames(GENERAL_CHAT_DOCK) should get you the table containing the different chat frames in the chat frame box.

If you also have undocked windows that you want to access then this may be the better option.

Lua Code:
  1. function WorkOnAllChatFrames()
  2.     local chatFrame, chatTab, conversationIcon;
  3.     for _, chatFrameName in pairs(CHAT_FRAMES) do
  4.        local frame = _G[chatFrameName];
  5.        chatFrame = frame;
  6.        chatTab = _G[chatFrame:GetName().."Tab"];
  7.        .... Do your stuff here
  8.     end
  9. end

Also, to clear the tab of text simply set the Window Name to "". window:clear() will clear the chat frame window of its messages instead.

SetChatWindowName(i, "")
__________________

Last edited by Xrystal : 11-05-18 at 03:53 AM.
  Reply With Quote
11-07-18, 05:39 PM   #3
myrroddin
A Molten Giant
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 944
Sorry for the delay as I was not at home. Anyway, if I understand it correctly, if I want to clear the text (I do not want to clear the tab names themselves) of both the chat frames and their docked windows, then this will work?
Lua Code:
  1. for i = 1, NUM_CHAT_WINDOWS do
  2.     local window = _G["ChatFrame"..i]
  3.     window:Clear()
  4.  
  5.     -- now clear docked tabs of their text
  6.     local chatFrame, chatTab
  7.     for _, chatFrameName in pairs(CHAT_FRAMES) do
  8.         local frame = _G[chatFrameName]
  9.         chatFrame = frame
  10.         chatTab = _G[chatFrame:GetName().."Tab"]
  11.         chatTab:Clear()
  12.     end
  13. end

Last edited by myrroddin : 11-07-18 at 05:41 PM. Reason: oops, typo
  Reply With Quote
11-08-18, 04:23 AM   #4
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,252
If it is the text on the Tabs you want to clear you want to access the Text element on the tab and set it to "".

There is a built in function that does this for you amongst other stuff. ChatFrameX:Clear() will clear out the chat history. tab:Clear() I don't think exists. tab:SetText("") will clear the tab text without changing the name of the Tab from ChatFrameXTab or whatever you may have renamed it as.

Lua Code:
  1. function FCF_SetWindowName(frame, name, doNotSave)
  2.   if ( not name or name == "") then
  3.     -- Hack to initialize the chat window names, since globalstrings are not available on init
  4.     if ( frame:GetID() == 1 ) then
  5.       name = GENERAL;
  6.       doNotSave = nil;
  7.     elseif ( frame:GetID() == 2 ) then
  8.       name = COMBAT_LOG;
  9.       doNotSave = nil;
  10.     else
  11.       name = format(CHAT_NAME_TEMPLATE, frame:GetID());
  12.     end
  13.   else
  14.     FCFDock_SetDirty(GENERAL_CHAT_DOCK);
  15.   end
  16.   frame.name = name;
  17. ----- v
  18.   local tab = _G[frame:GetName().."Tab"];
  19.   tab:SetText(name);
  20. ----- ^
  21.   PanelTemplates_TabResize(tab, tab.sizePadding or 0);
  22.   -- Save this off so we know how big the tab should always be, even if it gets shrunken on the dock.
  23.   tab.textWidth = _G[tab:GetName().."Text"]:GetWidth();
  24.   if ( not doNotSave ) then
  25.     SetChatWindowName(frame:GetID(), name);
  26.   end
  27.   if ( frame.minFrame ) then
  28.     frame.minFrame:SetText(name);
  29.   end
  30. end

On another note. The ChatFrames and DockedWindows are the same, you seem to be talking about them as if they are different things. The DockManager simply controls whether a ChatFrame is docked or not. So, ChatFrame1 is usually docked permanently as your main chatframe. ChatFrame2 similarly is the combat log and is usually docked permanently. All other frames ChatFrame3 to ChatFrame10 are dockable and floatable at the users whim. ChatFrame11 and higher are temporary chat frames that may be dockable ( I haven't looked at this side of things yet myself to confirm this ) but will have tabs that you may need to access. Which I think I pointed out before.
__________________

Last edited by Xrystal : 11-08-18 at 04:31 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Cycle through tabs in a chat window

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