Constructor
new RadioButton(textopt)
RadioButton constructor. Creates an instance of RadioButton UI component.
| Name | Type | Attributes | Description |
|---|---|---|---|
text | string | <optional> | Text of the radio button component. |
// Example how to group RadioButton components and detect when selected value of a group changes.
var mainForm = new Window("Demo").size(500, 300).show();
// create first RadioButton and sets group value change handler function
mainForm.radio1 = new RadioButton("Option 1").addTo(mainForm).position(10, 10).onChange(e => {console.log(e.value);});
// create second RadioButton and group it with first one
mainForm.radio2 = new RadioButton("Option 2").addTo(mainForm).position(10, 30).groupWith(mainForm.radio1);
// create third RadioButton and group it with first one
mainForm.radio3 = new RadioButton("Option 3").addTo(mainForm).position(10, 50).groupWith(mainForm.radio1);
// now when user clicks on any of these radio buttons a new selected value will be logged in console.Classes
Members
(readonly) group :Array.<RadioButton>
Retrieves an array of RadioButton components grouped with this component (including this component). Returns an array of minimum one (current) item.
- Array.<RadioButton>
Methods
clearSelection() → {RadioButton}
Deselect all RadioButton elements grouped with this element.
Returns this component.
- Type:
- RadioButton
groupWith(componentopt) → {RadioButton}
Adds this RadioButton to the group of another RadioButton, or removes it from its current group.
- Pass another RadioButtonMenuItem to join its group.
- Pass
nullto leave the current group (if any).
| Name | Type | Attributes | Description |
|---|---|---|---|
component | RadioButton | | <optional> | A RadioButton to join, or |
This RadioButton, for chaining.
- Type:
- RadioButton
selected(selectedopt) → {RadioButtonMenuItem|boolean}
Sets or gets boolean indicating whether this component is selected.
| Name | Type | Attributes | Description |
|---|---|---|---|
selected | boolean | <optional> |
|
Returns this CheckBoxMenuItem instance if argument is provided, otherwise returns boolean value.
- Type:
- RadioButtonMenuItem |
boolean
selectedValue() → {RadioButtonMenuItem|*}
Selects a radio button in the group of this component and has the specified value, or returns the value of selected radio button grouped with this component.
- Type:
- RadioButtonMenuItem |
*
value(valueopt) → {RadioButton|*}
Sets or gets a value of this component.
| Name | Type | Attributes | Description |
|---|---|---|---|
value | * | <optional> | Value to be held by this component |
If setting a value, then an instance of this component is returned, otherwise current value is returned.
- Type:
- RadioButton |
*