Get text from radio button

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
gepponline
Posts: 91
Joined: Tue Sep 03, 2013 1:53 pm

Get text from radio button

Post by gepponline » Fri Mar 06, 2015 3:35 pm

Hi!
how should i do to get the text of the selcted button of a radio button group?

I'm here:

Code: Select all

get the hilitedbutton of group MYRadioButtons
put it into tSelected
now i'd like to do domething like:

Code: Select all

put the text of item tSelected of group "MYRadioButtons" into FINALVARIABLE
obviously the last string of code is wrong...what should i use to do that?
thank you!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Get text from radio button

Post by dunbarx » Fri Mar 06, 2015 3:46 pm

Hi.

Buttons are containers, sort of like fields. They just do not display their data in readable form like a field. So you almost had it:

Code: Select all

put button "yourButton" into field "yourField"
Now you have to already have text in that button, and you do that the same way:

Code: Select all

put yourText into button "yourButton"
As for getting this from a group of radio buttons, you had that as well:

Code: Select all

on mouseUp
   answer the text of btn the hilitedButton of group "yourRadioButtonGroup"
end mouseUp
Craig Newman

EDIT:

I assume you really meant the text of a button, and not its name or label. True?

gepponline
Posts: 91
Joined: Tue Sep 03, 2013 1:53 pm

Re: Get text from radio button

Post by gepponline » Fri Mar 06, 2015 3:48 pm

Thank you.
Maybe i've found what i was looking for in another topic.

I should use hilitedbuttonname instead of hilitedbutton. :D

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

Re: Get text from radio button

Post by Klaus » Fri Mar 06, 2015 4:38 pm

Yes!

Or use this cumbersome way:

Code: Select all

...
## No need to use IT and ALWAYS put names in quotes!
put the hilitedbutton of group "MYRadioButtons" into tSelected
put the short name of btn tSelected of grp "MYRadioButtons" into FINALVARIABLE
...
:D

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

Re: Get text from radio button

Post by jacque » Fri Mar 06, 2015 7:08 pm

Note there's a difference between the text of a button and it's name. Sounds like you wanted the name. The text would give you its contents, like for example the list of menu items a pulldown button holds.

Edit : I see Craig already mentioned this. Oops.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: Get text from radio button

Post by SparkOut » Fri Mar 06, 2015 9:51 pm

Just to restate though, a radio button can also (probably will) have a label, which is the visible er.. label next to the radio button itself (unless you never set a label, in which case it will seem as if the label text displayed next to the button is the name). If someone selects the option against the label "Choice One" then quite possibly retrieving that label is more useful than the button name which might well be named for your own coding conventions rather than the benefit of a user, since in that case, it wouldn't be seen.

gepponline
Posts: 91
Joined: Tue Sep 03, 2013 1:53 pm

Re: Get text from radio button

Post by gepponline » Sat Mar 07, 2015 9:23 am

Yes you're right... I'm using unappropriatelt the name of the button but it' my very first app and I'm impatient to see the effect of my code before the correct programming method :)
but beeing here writing...

There is hilitedbutton and hilitedbuttonname

Is there even hilitedbuttonlabel or hilitedbuttontext or I have to use the 2 lines of code Klaus suggested for those elements of the button?

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

Re: Get text from radio button

Post by Klaus » Sat Mar 07, 2015 12:26 pm

Hi Geppo,
gepponline wrote:Is there even hilitedbuttonlabel or hilitedbuttontext or I have to use the 2 lines of code Klaus suggested for those elements of the button?
no, you will have to use my two lines, or make them one less readable line:
...
put the LABEL of btn (the hilitedbutton of group "MYRadioButtons") of grp "MYRadioButtons" into FINALVARIABLE
... 8)


Best

Klaus

Post Reply