Page 1 of 1

Selected button in a group

Posted: Thu Jul 21, 2011 1:09 pm
by askari
Hi,

I would like to hilite or set the opaque property of a button in a group to true when clicked but set it back to false when a user clicks on another button in the group. Any ideas on how to get this done?

im trying to do something like;

repeat with x = 1 to the number of buttons of group "buttons"
if on mouseup
set the opaque of me to true
else
set the opaque of me to false
end if
end repeat

though this syntax is not right it seems

Re: Selected button in a group

Posted: Thu Jul 21, 2011 1:44 pm
by SparkOut
One way to do it is to put in the group script:

Code: Select all

on mouseUp
   repeat with i = 1 to the number of buttons of me
      if the long id of the target is the long id of button i of me then
         set the opaque of button i of me to true
      else
         set the opaque of button i of me to false
      end if
   end repeat
end mouseUp

Re: Selected button in a group

Posted: Fri Jul 22, 2011 3:36 am
by askari
Sparkout,

Thanks for the reply, I tried this out but it doesn't seem to work. I placed the code in the group script

Re: Selected button in a group

Posted: Fri Jul 22, 2011 3:36 pm
by Klaus
Hi askari,

works for me!

Make sure the buttons do not have a "mouseup" handler of their own!
If you already added some "mouseup" handlers to your button, just add:

Code: Select all

on mouseup
  ## do your stuff here
  ## ...
  pass mouseup
end mouseup
as the last line of these handlers!
This way the group's script will also get executed!


Best

Klaus

Re: Selected button in a group

Posted: Fri Jul 22, 2011 8:37 pm
by askari
Klaus,

That worked perfectly,

Thanks much