Page 1 of 1

radio button group: how to get button names?

Posted: Tue Sep 08, 2015 8:07 am
by golive
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?

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

Posted: Tue Sep 08, 2015 8:37 am
by bn
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

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

Posted: Tue Sep 08, 2015 5:35 pm
by jacque
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.

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

Posted: Wed Sep 09, 2015 1:40 am
by golive
bn wrote: set the hilite of button tWhich of group 2 to true
Bernd
That's what I needed to know, thanks!

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

Posted: Wed Sep 09, 2015 1:41 am
by golive
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.

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

Posted: Wed Sep 09, 2015 1:55 pm
by Klaus
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

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

Posted: Thu Sep 10, 2015 2:15 am
by golive
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.