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

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
kunoir
Posts: 8
Joined: Fri Aug 30, 2013 6:03 am

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

Post by kunoir » Thu Dec 12, 2013 1:05 am

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

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

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

Post by Simon » Thu Dec 12, 2013 1:18 am

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

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

Post by dunbarx » Thu Dec 12, 2013 3:34 am

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

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

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

Post by keram » Fri Mar 28, 2014 11:53 am

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
Attachments
toggle hilite of the text field.zip
(718 Bytes) Downloaded 206 times
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Post Reply