Page 1 of 1

Making a button like a checkbox with icons for on and off.

Posted: Thu Dec 12, 2013 1:05 am
by kunoir
I want to have a button that has two states like a checkbox.

But I want the icon to change to make it obvious that it is selected.


I tried to use the code below but it didn't work.

on mouseUp
if variable = 0 then
put "4" into variable
set the armed of me to "true"
else
put "0" into variable
set the armed of me to "false"
end if
end mouseUp

Re: Making a button like a checkbox with icons for on and of

Posted: Thu Dec 12, 2013 1:18 am
by Simon
Hi kunoir,
You can
set the icon of me to image ID 1025 --use an image id for the 2 different states
or
set the highlight of me to false --This uses the buttons icon you've set up.

Simon

Re: Making a button like a checkbox with icons for on and of

Posted: Thu Dec 12, 2013 3:34 am
by dunbarx
Hi.

Or just go to the inspector and in the icon pane, select one for hilite and one for "normal" (icon). Note that most buttons do not toggle their hilites, rather only changing while the mouse is held down, though checkboxes and radioButtons do. But you can always do this with any button style by:

set the hilite of me to not the hllite of me

Craig Newman

Re: Making a button like a checkbox with icons for on and of

Posted: Fri Mar 28, 2014 11:53 am
by keram
Hi kunoir,

I just found your post searching for similar solution and worked out a way to toggle text fields and buttons just like checkboxes (you have to use a checkbox for this).

See the attached stack.

keram