change the size of the box in a checkbox

Kay C Lan lan.kc.macmail at gmail.com
Thu Oct 6 05:20:22 EDT 2005


On 10/4/05, rev at armbase.com <rev at armbase.com> wrote:
>
> Quoting Kay C Lan <lan.kc.macmail at gmail.com>:
>
> Hi Kay.
>
> This is a fantastic description. I was not aware of the image library
> method nor
> the Icon section. Only been using rev for fun for about 2 years but
> starting to
> do something serious now (well 10 hours a week).
>
> I can definitely go a long way with thins in so many ways.
>

OK, so now that you've had time to master that (which is another way of
saying I had to sleep, eat and work) I'll give you a tip, a trap and offer
one thought as to where you may go with this.

Tip
If you go to the the Image Library and hold the mouse over the image for a
second a 'toolTip' will pop up with the image ID number. This number can be
used to set an image from within a script.

Trap.
I'm sure your aware that if you open the Object Inspector and hold the mouse
over an editable field or checkbox for a second, a toolTip will pop-up with
the name of that property. This is great because it provides a very fast way
to find out the name of a property you wish to set, unfortunately there are
a few properties that are not named correctly so if you try to use them you
get errors, and icons are one of them.

If you go to the check box you created, and in the Object Inspector select
Icons & Borders and hold the mouse over the 5 top fields you'll get: Icon,
Hilite Icon, icon, icon & icon. Only the first one is correct!

If you go to Help, Docs, Dictionary, Filter with: 'icon' you'll discover
that what you really need is icon, hiliteIcon or hilitedIcon (same thing)
and disabledIcon.

So what can you do with this. I saw in another post you wanted to know about
having a preference stack and changing scripts depending on selections. Dan
answered that question but I'll offer a different way to do it. Remember
that 'script' is just another property so if you know how to set an object's
icon, you then know how to set it's script - or any other property for that
matter.

Let's say on your preference stack you have a option button (which is really
a menu!!) that sets the size of your check boxes. Lets call the button 'Set
Size' and it has three choices, Standard, Medium and Large.

Because an option/combo button is really a menu you have access to the
'menuPick' handler and the 'menuHistory' property. (Check them out in the
Dictionary for a full explanation). The menuPick handler does all the hard
work for you and you can use the menuHistory to determine what the last
selection was or to even change the selection in one simple statement - set
the menuHistory of button "Set Size" to 2

So having created the three images necessary for your 'Medium' check box,
and another 3 for your 'Large' check box, and imported them into your image
library and noted their ID numbers you can put this script into button 'Set
Size':

on menuPick tMyChoice --your choice is sent to here
switch tMyChoice --switch will look for a match
case ("Standard")
--remember setting them to zero will return to normal size
set the icon of button "CheckBox1" to 0
set the hilitedIcon of button "CheckBox1" to 0
set the disabledIcon of button "CheckBox1" to 0
set the rectangle of button "CheckBox1" to 25,25,65,47
break
case ("Medium")
-- you'll need to use your own IDs from your Image Library
set the icon of button "CheckBox1" to 1164
set the hilitedIcon of button "CheckBox1" to 1167
set the disabledIcon of button "CheckBox1" to 1189
set the rectangle of button "CheckBox1" to 15,15,75,52
break
case ("Large")
-- you'll need to use your own IDs from your Image Library
set the icon of button "CheckBox1" to 1203
set the hilitedIcon of button "CheckBox1" to 1213
set the disabledIcon of button "CheckBox1" to 1222
set the rectangle of button "CheckBox1" to 5,5,85,57
break
end switch
end menuPick

I've snuck in a 'the rectangle' property because obviously if you change the
size of the image, the whole button size will need to be changed to
accommodate it. You'll need to figure this out by setting up the button in
each configuration and using the Property Inspector to determine the numbers
that you need to set.

Obviously I did this for one check box, you could easily do if for many
either by adding more and more statements (for a couple) or using a repeat
statement (for lots).

So that should help you go 'a long way' and beyond;-)

HTH



More information about the use-livecode mailing list