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 » Thu Jul 21, 2011 1:09 pm

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: 2943
Joined: Sun Sep 23, 2007 4:58 pm

Re: Selected button in a group

Post by SparkOut » Thu Jul 21, 2011 1:44 pm

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 » Fri Jul 22, 2011 3:36 am

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: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Selected button in a group

Post by Klaus » Fri Jul 22, 2011 3:36 pm

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 » Fri Jul 22, 2011 8:37 pm

Klaus,

That worked perfectly,

Thanks much

Post Reply