Question

How do I get the value a user selects in a radio button group? Here is a simple code, what should I add in order to be able to retrieve the user selection? I couldn't find it in the docs.

view [
    radio "First"
    radio "Second"
    radio "Third"
]
Was it helpful?

Solution 2

probably not the only way, but you can set an external variable, as in

x: 0  
view [
  radio "First" on-action [set 'x 1]
  radio "Second" on-action [set 'x   2]
  radio "Third" on-action [set 'x 3]
]
print x

OTHER TIPS

In R3GUI radio buttons are grouped by proximity, and you can get their values by naming each button.

view [ 
   r1: radio "one"
   r2: radio "two"
   r3: radio "three"
   button "show" on-action [ print get-face reduce [ r1 r2 r3 ]]
]

You should use get-face and avoid looking at the internals when it's supported.

An other way

view [
  r1: radio "First"
  r2: radio "Second"
  r3: radio "Third"
]
print r1/state/value
print r2/state/value
print r3/state/value
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top