Selected button in a group

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
askari
Posts: 19
Joined: Fri Jul 01, 2011 11:45 pm

Selected button in a group

Post 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
SparkOut
Posts: 2984
Joined: Sun Sep 23, 2007 4:58 pm

Re: Selected button in a group

Post 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
askari
Posts: 19
Joined: Fri Jul 01, 2011 11:45 pm

Re: Selected button in a group

Post 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
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Selected button in a group

Post 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
askari
Posts: 19
Joined: Fri Jul 01, 2011 11:45 pm

Re: Selected button in a group

Post by askari »

Klaus,

That worked perfectly,

Thanks much
Post Reply