radio button group: how to get button names?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
golive
Posts: 98
Joined: Wed Jul 01, 2015 5:16 am

radio button group: how to get button names?

Post by golive » Tue Sep 08, 2015 8:07 am

I have 3 groups of radio buttons, called grpRadioA, grpRadioB and grpRadioC.

I know how to get the hilitedButtonName, using:

Code: Select all

 put the hilitedButtonName of group grpRadioA into cReturn
When conditions change, I want to specify which button is highlighted in each of the 3 groups.
is there a way to do that without hard coding in the name of the button?

Example:
The initial setting for grpRadioA and grpRadioB is have the first button highlighted.
The initial setting for grpRadioC is have the second button highlighted.

Is there a way to code that?

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: radio button group: how to get button names?

Post by bn » Tue Sep 08, 2015 8:37 am

Hi golive,

Code: Select all

on mouseUp
   lock screen
   if the name of the target contains "button" then
      put the hilitedButton of me into tBtnNumber
      put the number of buttons of me into tAllBtnsNo
      put tAllBtnsNo + 1 - tBtnNumber into tWhich
      set the hilite of button tWhich of group 2 to true
   end if
   unlock screen
end mouseUp
for 3 radio buttons in a group and 3 radio button in a second group
place this script into the group script of group 1

this will hilite a radio button in response to the hilitedButton of group 1

Of course you would want to name the buttons and groups and all that.

Kind regards
Bernd

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: radio button group: how to get button names?

Post by jacque » Tue Sep 08, 2015 5:35 pm

Another way would be to set a custom property in each group that holds the number of the default hilitedButton. Then you can just read that, if I understand the question right.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

golive
Posts: 98
Joined: Wed Jul 01, 2015 5:16 am

Re: radio button group: how to get button names?

Post by golive » Wed Sep 09, 2015 1:40 am

bn wrote: set the hilite of button tWhich of group 2 to true
Bernd
That's what I needed to know, thanks!

golive
Posts: 98
Joined: Wed Jul 01, 2015 5:16 am

Re: radio button group: how to get button names?

Post by golive » Wed Sep 09, 2015 1:41 am

jacque wrote:Another way would be to set a custom property in each group that holds the number of the default hilitedButton. Then you can just read that, if I understand the question right.
Good idea!
Thanks for the suggestion.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: radio button group: how to get button names?

Post by Klaus » Wed Sep 09, 2015 1:55 pm

Hi golive,
golive wrote:
bn wrote: set the hilite of button tWhich of group 2 to true
Bernd
That's what I needed to know, thanks!
(Almost) Everything that you can GET can also be SET in Liveocode!
So you can of course:
...
set the hilitedbutton of grp "RadioA" to 1
...
set the hilitedbuttonname of grp "RadioA" to "Radiobutton1"
...

Best

Klaus

golive
Posts: 98
Joined: Wed Jul 01, 2015 5:16 am

Re: radio button group: how to get button names?

Post by golive » Thu Sep 10, 2015 2:15 am

Klaus wrote: (Almost) Everything that you can GET can also be SET in Liveocode!
So you can of course:
...
set the hilitedbutton of grp "RadioA" to 1
...
set the hilitedbuttonname of grp "RadioA" to "Radiobutton1"
...
OIC, useful to know.
Thanks.

Post Reply