Page 1 of 1
[Newbie Question] hilite of button 1 group 1 -- help please
Posted: Thu Jul 24, 2014 1:31 pm
by shawnblc
Here's my code. What I'm trying to do is if the check box is checked then at least one in the group needs checked.
Code: Select all
if the hilite of btn "1" is true and the hilite of group "group1" is false then
set the visible of graphic "rec1" to true
else
set the visible of graphic "rec1" to false
end if
Re: [Newbie Question] hilite of button 1 group 1 -- help ple
Posted: Thu Jul 24, 2014 2:01 pm
by Klaus
Hi shawn,
1. it is a really bad idea to give objects a name with a "pure" NUMBER!
Beause the engine will get confused and treats -> button "1" as the button with the NUMBER 1
(lowest layer) even if that button is actually button number 666!
Use something like -> button "b1"
2. GROUPS do not have a hilite property, so what exactly do you want to achieve with:
the hilite of group "group1" ?
Best
Klaus
Re: [Newbie Question] hilite of button 1 group 1 -- help ple
Posted: Thu Jul 24, 2014 2:04 pm
by shawnblc
Klaus wrote:Hi shawn,
1. it is a really bad idea to give objects a name with a "pure" NUMBER!
Beause the engine will get confused and treats -> button "1" as the button with the NUMBER 1
(lowest layer) even if that button is actually button number 666!
Use something like -> button "b1"
2. GROUPS do not have a hilite property, so what exactly do you want to achieve with:
the hilite of group "group1" ?
Best
Klaus
Point taken. I'll make those changes.
What I'm trying to accomplish is this (see below example):
[] Clothes
[] Pants
[] Shorts
[] Shoes
[] Socks
so if clothes is checked, then at least on of the others should be checked. If not I need a red graphic that shows around the group (pants, shorts, shoes, socks).
Re: [Newbie Question] hilite of button 1 group 1 -- help ple
Posted: Thu Jul 24, 2014 2:16 pm
by Klaus
Hi shawn,
shawnblc wrote:What I'm trying to accomplish is this (see below example):
[] Clothes
[] Pants
[] Shorts
[] Shoes
[] Socks
so this is a group of radiobuttons?
shawnblc wrote:so if clothes is checked, then at least on of the others should be checked. If not I need a red graphic that shows around the group (pants, shorts, shoes, socks).
If yes, you can check:
1. the hilitedbutton of grp "your radio group here"
Will return the NUMBER Of that button in the group
OR
2. the hilitedbuttonname of grp "your radio group here"
Will return the NAME of the button
So you could do something like this in the group script:
Code: Select all
on mouseup
switch the hilitedbuttonname of me
case "Clothes"
## do whatever needs to be done...
break
case "Pants"
## do whatever you need to to in case the user selected PANTS
break
## etc...
end switch
end mouseup
You get the picture
Best
Klaus
Re: [Newbie Question] hilite of button 1 group 1 -- help ple
Posted: Thu Jul 24, 2014 2:23 pm
by shawnblc
No it's checkboxes.
Re: [Newbie Question] hilite of button 1 group 1 -- help ple
Posted: Thu Jul 24, 2014 2:58 pm
by magice
how about something like this:
Code: Select all
put false into tButtonCheck
repeat with i = 1 to the number of buttons in group "group1"
if the hilite of button i of group "group1" is true then put true into tButtonCheck
end repeat
if the hilite of btn "1" is true and tButtonCheck is false then
set the visible of graphic "rec1" to true
else
set the visible of graphic "rec1" to false
end if
not tested, but I think you'll get the idea.
Re: [Newbie Question] hilite of button 1 group 1 -- help ple
Posted: Thu Jul 24, 2014 3:00 pm
by Klaus
shawnblc wrote:No it's checkboxes.
AHA!
so you need to check if one of:
[] Pants
[] Shorts
[] Shoes
[] Socks
Is checked at all or ALL are unchecked?
I ususally write little function for this:
Code: Select all
function is_something_checked
repeat for each item tButton in "pants,shorts,shoes,socks"
if the hilite of btn i = TRUE then
## At least ONE button has been checked
return TRUE
end if
end repeat
## No button checked:
return FALSE
end is_something_checked
Hope that helps!
Best
Klaus