WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Radio button like table? (https://www.wowinterface.com/forums/showthread.php?t=55934)

Layback_ 12-26-17 08:20 PM

Radio button like table?
 
Hi again all,

Hope everyone had a great Christmas and having a great end of years holiday!!!

So, lets say we have three radio buttons and they are in a same group. As we all know, selecting either of them will deselect the rest and vice versa. My question is if there is a such kind of table function built in Lua which sets the rest to false apart from the one that user has chosen, or should I just create one myself with metatable thing?

Thank you in advance :D

Fizzlemizz 12-26-17 08:34 PM

If you look at the Garrison UI for the recruiter in your Garrison Inn (if you have one), Blizzard version of a radio uses CheckButtons and:

Code:

function GarrisonRecruiterType_OnClick( self )
        CloseDropDownMenus();
        local frame = GarrisonRecruiterFrame.Pick;
        if( self:GetID() == 1 ) then
                frame.Radio1:SetChecked(true);
                frame.Radio2:SetChecked(false);
                GarrisonRecruiterFrame_UpdateAbilityEntries(false);
                frame.Title2:SetText(GARRISON_CHOOSE_THREAT);
        else
                frame.Radio1:SetChecked(false);
                frame.Radio2:SetChecked(true);
                GarrisonRecruiterFrame_UpdateAbilityEntries(true);
                frame.Title2:SetText(GARRISON_CHOOSE_TRAIT);
        end
end

So, nothing "native".

There is the UIRadioButtonTemplate for creating the "dot" button.

MunkDev 12-26-17 08:38 PM

I usually put every checkbutton in a table and then use something like this as a general OnClick script:
Lua Code:
  1. local function CheckOnClick(self)
  2.     for _, button in ipairs(self.siblings) do
  3.         button:SetChecked(false)
  4.     end
  5.     self:SetChecked(true)
  6. end

Layback_ 12-26-17 09:01 PM

Thank you Fizzlemizz and MunkDev!

Guess I'll have to create my own version of it, then :D

Again, hope you guys have a great end of year's holidays :banana:

Fizzlemizz 12-26-17 09:11 PM

The more common in-game "default" for a radio type action would be the scroll or drop(scroll).

You have a great New Years also :banana:


All times are GMT -6. The time now is 01:55 PM.

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