How to auto-select radio buttons

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
ali
Posts: 2
Joined: Wed Apr 08, 2015 6:55 pm

How to auto-select radio buttons

Post by ali » Thu Apr 09, 2015 5:48 pm

First time poster:
I have 3 radio buttons. I want radio buttons 2 and 3, to get auto-selected if radio button 1 is manually selected. I have searched for "radio buttons" and could not find relevant content.

Any help is appreciated.

sritcp
Posts: 431
Joined: Tue Jun 05, 2012 5:38 pm

Re: How to auto-select radio buttons

Post by sritcp » Thu Apr 09, 2015 6:48 pm

ali wrote:I have searched for "radio buttons" and could not find relevant content.
1. User Manual (accessible from within LiveCode program) gives an overview of radio buttons.
2. Don't miss the scripting conference materials, downloadable at
http://www.hyperactivesw.com/revscriptc ... ences.html
The third chapter on "Controls" by Klaus is what you need. A must read!

"Radio" buttons have a specific meaning (and characteristic). When you select one, the others are "auto DE-selected", not auto-selected. Is this what you need?
Again, do the scripting conference tutorial mentioned above.
These are in the form of stacks. You open them in LiveCode and follow along.

Regards,
Sri.

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

Re: How to auto-select radio buttons

Post by dunbarx » Thu Apr 09, 2015 8:17 pm

What Sri said.

But you can have it any way you want, since you are in charge, though I might suggest using checkBoxes instead of radio buttons.

Anyway, if you are a first time poster, does that mean you have some experience with writing handlers? Let me know, and I will give you a few small learning tasks that will get your buttons in a row.

Craig Newman

ali
Posts: 2
Joined: Wed Apr 08, 2015 6:55 pm

Re: How to auto-select radio buttons

Post by ali » Fri Apr 10, 2015 5:11 pm

Below is snippet that does what I needed:
/*
on mouseUp
if the hilite of me then
set the hilite of btn "c2" to true
set the hilite of btn "c3" to true
else
set the hilite of btn "c2" to false
set the hilite of btn "c3" to false
end if
end mouseUp
*/
Note: c1, c2 and c3 are check-button names. c1 manipulates c2 and c3 but not vice versa.

Thanks for your helpful inputs.

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

Re: How to auto-select radio buttons

Post by dunbarx » Fri Apr 10, 2015 5:28 pm

HI..

Just so.

A little more elegant, and this is only a matter of style:

Code: Select all

on mouseUp
  set the hilite of btn "c2" to the hilite of me
  set the hilite of btn "c3" to the hilite of me
end mouseUp
But if you look at this, you might get a little "Eureka" on the subject of how cool LC is.

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: How to auto-select radio buttons

Post by FourthWorld » Fri Apr 10, 2015 5:38 pm

Put the buttons in a group and the user interaction is handled automatically. To set the hilitedButton of a group see the hilitedButton, hilitedButtonID, and hilitedButtonName properties in the Dictionary.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply