WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Is possible to open Guild (or communities) Frame to a specific TAB ? (https://www.wowinterface.com/forums/showthread.php?t=57881)

gmarco 03-18-20 11:04 AM

Is possible to open Guild (or communities) Frame to a specific TAB ?
 
Hi everyone.

I am writing a small addon and I'd like to show the guild frame directly in the "Roster" tab.

The problem is that if I call:

Lua Code:
  1. ToggleGuildFrame()
  2.  
  3. or
  4.  
  5. ToggleCommunitiesFrame()

It opens in the "Chat" tab which I think is the default.
I tried to read the wow interface source and I think it is not possible to pass a param to choose one tab I want to open like:

Lua Code:
  1. ToggleFriendsFrame(3)

for example.

But I am a neewbie and so I ask for a confirmation here :)
Any idea ? Tips ? Tricks ?

Thanks :)

Seerah 03-18-20 11:39 AM

Looking through Blizzard's code, try this
Lua Code:
  1. GuildFrame_TabClicked(GuildFrameTab2)

Fizzlemizz 03-18-20 11:41 AM

Code:

ToggleGuildFrame()
CommunitiesFrame.GuildInfoTab:GetScript("OnClick")(CommunitiesFrame.GuildInfoTab)


Fizzlemizz 03-18-20 11:46 AM

I took the lazy option :D

gmarco 03-18-20 10:24 PM

Hi,

thanks so much for help, but both solutions dont work :/ .

May I miss something ?

Thanks .

Fizzlemizz 03-18-20 10:32 PM

As an addon (retail) running /gdo using the code below opens the guild window to the guild information tab.

If the frame isn't shown, it will open it and if it is shown but on another tab it will open the info tab.

Lua Code:
  1. SLASH_GLDOPEN1 = "/gdo"
  2. SlashCmdList["GLDOPEN"] = function()
  3.     if not CommunitiesFrame or not CommunitiesFrame:IsShown() then
  4.         ToggleGuildFrame()
  5.     end
  6.     CommunitiesFrame.GuildInfoTab:GetScript("OnClick")(CommunitiesFrame.GuildInfoTab)
  7. end

Even if you're not in a guild so it would probably be best to use a "in guild" check.

gmarco 03-19-20 09:00 AM

Thanks so much for your reply Fizzlemizz.

The tab name was the wrong one :) but finally you give me the advice to find how to find the right name.

Google gives me 2 results, one was this:



The problem is that the tab is selected correctly but it is not activated.



Any idea ?
Thanks

Fizzlemizz 03-19-20 09:13 AM

You need to change both instances of the tab frame name in the call.

Code:

CommunitiesFrame.RosterTab:GetScript("OnClick")(CommunitiesFrame.RosterTab)
Otherwise you're calling the roster tab but passing in the info tab which then becomes "self" for the OnClick script.

Seerah's method would be better but I don't have time to rumage through the code.

gmarco 03-19-20 12:09 PM

Omg :)

I saw the finger but not the moon :)
It does work now as expected :)

The Seerah's solution had to work, I have found on internet a lot of evidences of it after she proposed but it doesn't for me :/

For example:




Sorry again for my mistake and thanks again.

Fizzlemizz 03-19-20 12:31 PM

Doing it the proper (Seerah) way it would be:

Code:

if not CommunitiesFrame or not CommunitiesFrame:IsShown() then
        ToggleGuildFrame()
end
CommunitiesFrame:SetDisplayMode(COMMUNITIES_FRAME_DISPLAY_MODES.ROSTER)

Although they both end up doing the same thing, my way adds 2 additional function calls (GetScript and the OnClick call).

XML for the roster tab:
Code:

<CheckButton name="CommunitiesRosterTabTemplate" hidden="true" inherits="CommunitiesFrameTabTemplate" virtual="true">
        <KeyValues>
                <KeyValue key="tooltip" value="COMMUNITIES_ROSTER_TAB_TOOLTIP" type="global"/>
        </KeyValues>
        <Scripts>
                <OnLoad>
                        self.Icon:SetTexture("Interface\\Icons\\achievement_guildperk_everybodysfriend");
                </OnLoad>
                <OnClick inherit="append">
                        self:GetParent():SetDisplayMode(COMMUNITIES_FRAME_DISPLAY_MODES.ROSTER);
                </OnClick>
        </Scripts>
</CheckButton>


gmarco 03-19-20 12:58 PM

Yes !

Now it works like a charm :)

Thanks so much :)


All times are GMT -6. The time now is 05:53 PM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI