radio button behaviour
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
radio button behaviour
I set radioButtonBehaviour to false (6 in a group) then add code instructing that only two at one time can be selected: (I have done it with numbers) ...if number of chars in Numb = 2 then ....
How do I use this same concept with buttons and checkboxes?
How do I use this same concept with buttons and checkboxes?
Re: radio button behaviour
Chris,
Some code of what you did would be helpful (to see exactly what you want to accomplish with just buttons and checkboxes), but sans that:
For determining whether a checkbox is checked, you can use the following phrase:
This will return true if it is checked, and false otherwise. With this ability, it is a matter of simply keeping track of which checkboxes are highlighted, and which aren't. It would also probably be convenient to have a global variable that keeps track of the number of the checkboxes that are selected (if your controls are not grouped), or a local script variable that serves the same purpose (if your controls are grouped). In this case, I would definitely recommend grouping.
The radioButtonBehavior option is merely a convenience provided to you by the LiveCode folks. Having standalone checkboxes that you must create logic for is the equivalent of having a set of radio buttons, where you elect to set the radioButtonBehavior to false.
How you want to "allow" or "disallow" a user from selecting a third checkbox was not specified in your original post, but is easy to do to using the enabled or visible properties of controls (depending on the look and overall behavior you want).
or
If you do implement the logic in a group (as I recommend), and there is a need to differentiate between which checkboxes are selected, I would use the following code:
If you only care about the number of checkboxes that are selected, then in your group handler:
With the information given, I'm unsure how or why you would use buttons instead of checkboxes or radio buttons. Some more information will allow me to help you more.
Tom
Some code of what you did would be helpful (to see exactly what you want to accomplish with just buttons and checkboxes), but sans that:
For determining whether a checkbox is checked, you can use the following phrase:
Code: Select all
the hilite of button "theButton"
The radioButtonBehavior option is merely a convenience provided to you by the LiveCode folks. Having standalone checkboxes that you must create logic for is the equivalent of having a set of radio buttons, where you elect to set the radioButtonBehavior to false.
How you want to "allow" or "disallow" a user from selecting a third checkbox was not specified in your original post, but is easy to do to using the enabled or visible properties of controls (depending on the look and overall behavior you want).
Code: Select all
set the enabled of button "theButton" to {true|false}//Choose either true or false in your code, omitting the {}
Code: Select all
set the visible of button "theButton" to {true|false}
Code: Select all
on mouseUp
put the short name of the target into theTarget
switch theTarget
case "button1"
--code here
break
case "button2"
--code here
break
--etc.
end switch
end mouseUp
Code: Select all
sNumberChecked = 0
on mouseUp
--add code to count the number of checkboxes whose hilite is true here. Set sNumberChecked accordingly
end mouseUp
Tom
Re: radio button behaviour
Hi Chris,
count all hilited buttons and then act accordingly
Add this script to the group with your buttons, of course the buttons need to be set to autohilite = FALSE!
Best
Klaus
just like you would do in "real life" with a piece of paper and a pencil,chris25 wrote:...How do I use this same concept with buttons and checkboxes?
count all hilited buttons and then act accordingly

Add this script to the group with your buttons, of course the buttons need to be set to autohilite = FALSE!
Code: Select all
## Or whatever you like:
constant maxHilites = 2
on mouseUp
## UN-hiliting is always allowed
if the hilite of the target = TRUE then
set the hilite of the target to FALSE
exit mouseup
end if
## I use this little function below to see if the button is allowed to hilite:
set the hilite of the target to check4hilite()
end mouseUp
## No witchcraft, just count all hilited buttons :-)
function check4hilite
put 0 into tCounter
repeat with i = 1 to the num of buttons of me
if the hilite of btn i of me = TRUE then
add 1 to tCounter
end if
end repeat
## I just love Monsieur Boole :-)
return (tCounter < maxHilites)
end check4hilite
Klaus
Re: radio button behaviour
So the first three cards are how the user would navigate through a series of choices. The last card was an alternative method so I can learn variation in coding.(Sorry , this last card is not allowed to be uploaded I imagine, it was one with checkboxes on it where the user was allowed to click two boxes (the print size and the resolution before being taken to the final answer) I am particularly wanting to be able to learn by using global variables, scope local variables and temporary variables. I can define these, I have answered the questions correctly, I have done the exercises and got my PHD

Hope this clarifies my first post.
Thankyou.
Re: radio button behaviour
Experimenting is always the best way to gain experience.
Might I also suggest, as a way of getting ideas and knowing how things "should be" written, to look at some applications that you use daily that you find easy to use. Invariably, if you learn how to mimic these, you too will create applications others find useful!
Keep it up,
Tom
Might I also suggest, as a way of getting ideas and knowing how things "should be" written, to look at some applications that you use daily that you find easy to use. Invariably, if you learn how to mimic these, you too will create applications others find useful!
Keep it up,
Tom
Re: radio button behaviour
Thanks Tom, and point taken.
Re: radio button behaviour
As an addendum: radio buttons are universally recognized in all operating systems as allowing a single choice among a group of choices. Selecting one deselects the others, which is the default behavior of LiveCode radio buttons.
Checkboxes are universally considered multiple-choice options, and any number can be selected.
For what you want, I'd use checkbox buttons.
Checkboxes are universally considered multiple-choice options, and any number can be selected.
For what you want, I'd use checkbox buttons.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com