AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YChart | YDAT | YWAIT | Byzgraf | FAQs
CheckboxGroup typedict
 
A CheckboxGroup is the interface to Java's AWT CheckboxGroup that is used to impose radio button behavior (i.e., at most one checkbox can be selected) on one or more checkboxes. Yoix programs normally interact with a CheckboxGroup by reading or writing the following field:
model An int that determines what is returned when the selected field is read. Setting model to 0, which is the default, means your program gets a string that is a copy of the selected checkbox's command field, if it's not NULL, or the text field if command is NULL. Setting model to 1 means your program gets a checkbox when the selected field is read.
selected A Checkbox that represents the checkbox that is selected by the group. Reading returns a value, either a string or the selected checkbox, that is determined by the model field. Writing immediately sets the group's selected checkbox to the new value. Writing a NULL value clears all checkboxes.
Several permanent fields have not been documented and should not be used in Yoix applications. Assigning a CheckboxGroup to a checkbox's group field automatically adds that checkbox to the group.
 
 Example:   The program,
import yoix.*.*;

CheckboxGroup cbg;

Frame f = {
    FlowLayout layoutmanager = {
        int vgap = 72;
        int hgap = 18;
    };

    Array layout = {
        new Checkbox {
            CheckboxGroup group = cbg;
            String        text = "Label 1";
            int           state = 1;
        },

        new Checkbox {
            CheckboxGroup group = cbg;
            String        text = "Label 2";
            int           state = 1;
        },

        new Checkbox {
            CheckboxGroup group = cbg;
            String        text = "Exit";
            int           state = 0;

            itemStateChanged(e) {
                if (e.state) {
                    printf("You selected: %s\n", cbg.selected);
                    exit(0);
                }
            }
        },
    };
};

f.visible = TRUE;
puts three checkboxes in the same group, adds them to a frame, and prints,
You selected: Exit
on standard output right before quitting when the last checkbox is selected.
 
 See Also:   Checkbox

 

Yoix is a registered trademark of AT&T Inc.