How to check the Checkbox?

Sarah Reichelt sarahr at genesearch.com.au
Wed Jan 9 17:18:01 EST 2002


> 1. I have a checkbox, next to it is a textfield.
> 2. Another button  sends  a command (on mouseUp) to the checkbox. Then..
> 3. If the checkbox is "on", I want the text, in the field next to it, to
> be put  in another textfield.
> 
> 4. How do I check the checkbox? I tried  this:
> 
> on plusOrder
> if btn ID 1118 then put fld ID 1115 & tab & fld ID 1116 into field
> "order"
> end plusOrder
> 
> I also tried the "selected"-property. But nothing happend. Not even
> error.

To set the check of a checkbox, use it's hilite property
e.g. 
    set the hilite of btn "My Checkbox" to true
    set the hilite of btn "Other Checkbox" to false

In your other button that is controlling the checkbox, you need something
like this:

    on mouseUp
        set the hilite of btn "My Checkbox" to true
        send mouseUp to btn "My Checkbox"
    end mouseUp

Then in the checkbox itself:

    on mouseUp
        if the hilite of me then put fld "First" into fld "Second"
    end mouseUp

> 
> One other thing, can I send a command (from a button) to a group
> (containing several checkboxies) and every checkbox react to the command?

I think you need to write a script in the group itself to do this. Here's
one I tried:

    on doStuff
      repeat with b = 1 to the number of btns in me
        if the style of btn b of me = "checkBox" then
          -- do whatever you want with that checkbox
        end if
      end repeat
    end doStuff

As this handler is in the group's script, "me" refers to the group.

Then in your other button, have:

    send doStuff to group "Whatever"

Cheers,
Sarah




More information about the use-livecode mailing list