The next two chapters describe the two components CheckBox and RadioButton. Each component has its own specific function:
Figure 16.17.1: Three CheckBoxes and a group of three RadioButtons
Control element CheckBox
The control element CheckBox (gb.qt4) implements a CheckBox that can be selected or not. If the tristate property is defined, then the CheckBox state is interpreted as “state unknown (not defined)” or “should not be changed”.
Property | Type | Default | Description |
---|---|---|---|
Autoresize | Boolean | False | Determines the value or determines whether the size of the CheckBox automatically adapts to the descriptive text. |
Text | String | Null | Determines the text or specifies the text to be displayed on the CheckBox as caption. |
Caption | String | Null | Synonym for Text |
Tristate | Boolean | False | Determines or determines whether the CheckBox has a third state. |
Value | Integer | 0 | Determines or determines which value the CheckBox has. |
Table 16.17.1: Properties CheckBox
The property CheckBox.Value can have three values -1, 0 or 1, which applies to the state in connection with the defined CheckBox constants and the .Tristate property:
Symbol | Condition | Value | Constant |
---|---|---|---|
☑ | Selected | -1 | CheckBox.True |
⎕ | Not selected | 0 | CheckBox.False |
⊟ | Indeterminate | 1 | CheckBox.None ( + CheckBox.Tristate = True) |
Table 16.17.2: Values of the property CheckBox.Value
The click event is triggered when the user clicks on the checkbox and the state of the checkbox changes. If CheckBox.Tristate = False, then the state changes alternatively. Otherwise, the order is:⎕ → ⊟ → ☑ .You can quickly convince yourself of this if you set the CheckBox.Tristate property to True or False for a CheckBox and use this event handling routine:
Public Sub CheckBox1_Click() Select CheckBox1.Value Case -1 Print "CheckBox checked" ' State: selected Case 0 Print "CheckBox unchecked" ' State: not selected Case CheckBox1.None Print "CheckBox indeterminate" ' State: indifferent End Select End ' CheckBox1_Click()
This is remarkable: The complete source code (trunk/) of gambas show an application of CheckBox.Tristate only in the supplied example GameOfLife.
Articles