Thread Tools Display Modes
12-26-17, 08:20 PM   #1
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
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

Last edited by Layback_ : 12-26-17 at 08:32 PM.
  Reply With Quote
12-26-17, 08:34 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,857
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.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 12-26-17 at 09:05 PM.
  Reply With Quote
12-26-17, 08:38 PM   #3
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
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
__________________
  Reply With Quote
12-26-17, 09:01 PM   #4
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
Thank you Fizzlemizz and MunkDev!

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

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

Last edited by Layback_ : 12-26-17 at 09:11 PM.
  Reply With Quote
12-26-17, 09:11 PM   #5
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,857
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
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 12-26-17 at 09:13 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Radio button like table?

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