From Clomosy Docs

No edit summary
No edit summary
Line 1: Line 1:
Radio buttons, also called option buttons, present a set of mutually exclusive choices. You can create individual radio buttons using TClRadioButton. A selected radio button is displayed as a circle filled in the middle. When not selected, the radio button shows an empty circle.
<div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert">
function AddNewRadioButton(AComponent: TCLComponent; xName, xCaption: string): TclRadioButton;
</div>


AddNewRadioButton(TComponent, xName, xCaption): TclRadioButton
<span style="color:blue"><b>AComponent</b></span> : The variable name of the defined component is written. Here you should write the component variable name of whatever your component will be in.<br>


<span style="color:blue"> TComponent</span> : The variable name of the defined component is written. Here you should write the component variable name of whatever your component will be in.
<span style="color:blue"><b>xName</b></span> : The name of the defined radio button should be written.<br>


<span style="color:blue"> xName</span> : The name of the defined radio button should be written.
<span style="color:blue"><b>xCaption</b></span> : You can add a title.<br>


<span style="color:blue"> xCaption</span> : You can add a title.
Radio buttons, also called option buttons, present a set of mutually exclusive choices. You can create individual radio buttons using TClRadioButton. A selected radio button is displayed as a circle filled in the middle. When not selected, the radio button shows an empty circle.<br>


<div class="table-responsive">
{| class="wikitable" style="border: 2px solid #c3d7e0"
{| class="wikitable" style="border: 2px solid #c3d7e0"
! style="background-color: #c3d7e0"| Feature !!style="background-color: #c3d7e0"| Use of !!style="background-color: #c3d7e0"|Definition  
! style="background-color: #c3d7e0"| Feature !!style="background-color: #c3d7e0"| Use of !!style="background-color: #c3d7e0"| Definition  
|-
|-
|TclRadioButton || RadioButton1 : TclRadioButton; || A variable belonging to the TclRadioButton class is created.
|TclRadioButton || RadioButton1 : TclRadioButton; || A variable belonging to the TclRadioButton class is created.
|-
|-
|AddNewRadioButton || RadioButton1 = MyForm.AddNewRadioButton(MyForm,'RadioButton1','Test Radio Button Caption'); || A new TclRadioButton is added to the form.
|AddNewRadioButton || RadioButton1 = Form1.AddNewRadioButton(Form1,'RadioButton1','Test Radio Button Caption'); || A new TclRadioButton is added to the form.
|-
|-
|Width || RadioButton1.Width = 150; ||Allows adjusting the width of the radioButton.
|Width || RadioButton1.Width = 150; ||Allows adjusting the width of the radioButton.
Line 30: Line 34:
|isChecked ||RadioButton1.isChecked = True; || Assign the value True or False to the Checked property to change the radio button's visual state. As soon as it is correct, it will come selected.
|isChecked ||RadioButton1.isChecked = True; || Assign the value True or False to the Checked property to change the radio button's visual state. As soon as it is correct, it will come selected.
|}
|}
</div>
<b>Example</b><br>


'''Example:'''<br>
Example let's put 2 radioButtons on the form. Here, when one is clicked and I click on the other, we will see that the clicked one is unticked. Now you can create a project with the options you want in the design you want with the radioButton.<br>
Example let's put 2 radioButtons on the form. Here, when one is clicked and I click on the other, we will see that the clicked one is unticked. Now you can create a project with the options you want in the design you want with the radioButton.<br>


:'''TRObject Syntax'''
<pre>
 
var
  var
  MyForm:TclForm;
    MyForm:TclForm;
  testButton : TclButton;
    testButton : TclButton;
  testRadio,testRadio2 : TClRadioButton;
    testRadio,testRadio2 : TClRadioButton;
 
void ButtonClicked;
  void ButtonClicked;
{
  {
  testRadio.isChecked =  not testRadio.isChecked;
    testRadio.isChecked =  not testRadio.isChecked;
}
  }
 
{
  {
  MyForm = TclForm.Create(Self);
    MyForm = TclForm.Create(Self);
  testButton= MyForm.AddNewButton(MyForm,'testButton','Click');
    testButton= MyForm.AddNewButton(MyForm,'testButton','Click');
  testButton.TextSettings.Font.Size=50;
    testButton.TextSettings.Font.Size=50;
  testButton.Align = alCenter;
    testButton.Align = alCenter;
  testButton.Height = 50;
    testButton.Height = 50;
  testButton.Width = 100;
    testButton.Width = 100;
 
   
  testRadio = MyForm.AddNewRadioButton(MyForm,'testRadio','Female');
    testRadio = MyForm.AddNewRadioButton(MyForm,'testRadio','Female');
  testRadio.StyledSettings = ssFamily;
    testRadio.StyledSettings = ssFamily;
  testRadio.TextSettings.Font.Size=25;
    testRadio.TextSettings.Font.Size=25;
  testRadio.TextSettings.FontColor = clAlphaColor.clHexToColor('#8a067c');
    testRadio.TextSettings.FontColor = clAlphaColor.clHexToColor('#8a067c');
  testRadio.Align = alTop;
    testRadio.Align = alTop;
  testRadio.Height = 30;
    testRadio.Height = 30;
 
   
  testRadio2 = MyForm.AddNewRadioButton(MyForm,'testRadio2','Male');
    testRadio2 = MyForm.AddNewRadioButton(MyForm,'testRadio2','Male');
  testRadio2.StyledSettings = ssFamily;
    testRadio2.StyledSettings = ssFamily;
  testRadio2.TextSettings.Font.Size=25;
    testRadio2.TextSettings.Font.Size=25;
  testRadio2.TextSettings.FontColor = clAlphaColor.clHexToColor('#8a067c');
    testRadio2.TextSettings.FontColor = clAlphaColor.clHexToColor('#8a067c');
  testRadio2.Align = alTop;
    testRadio2.Align = alTop;
  testRadio2.Height = 30;
    testRadio2.Height = 30;
 
   
  MyForm.AddNewEvent(testButton,tbeOnClick,'ButtonClicked');
    MyForm.AddNewEvent(testButton,tbeOnClick,'ButtonClicked');
 
   
  MyForm.Run;
    MyForm.Run;
}
  }
</pre>
 
:'''Base Syntax'''
'''var'''
MyForm:TclForm;
testButton : TclButton;
testRadio,testRadio2 : TClRadioButton;<br>
'''procedure''' ButtonClicked;
'''begin'''
  testRadio.isChecked :=  not testRadio.isChecked;
'''end;'''<br>
'''begin'''
MyForm := TclForm.Create(Self);
testButton:= MyForm.AddNewButton(MyForm,'testButton','Click');
testButton.TextSettings.Font.Size:=50;
testButton.Align := alCenter;
testButton.Height := 50;
testButton.Width := 100;<br>
testRadio := MyForm.AddNewRadioButton(MyForm,'testRadio','Female');
testRadio.StyledSettings := ssFamily;
testRadio.TextSettings.Font.Size:=25;
testRadio.TextSettings.FontColor := clAlphaColor.clHexToColor('#8a067c');
testRadio.Align := alTop;
testRadio.Height := 30;<br>
testRadio2 := MyForm.AddNewRadioButton(MyForm,'testRadio2','Male');
testRadio2.StyledSettings := ssFamily;
testRadio2.TextSettings.Font.Size:=25;
testRadio2.TextSettings.FontColor := clAlphaColor.clHexToColor('#8a067c');
testRadio2.Align := alTop;
testRadio2.Height := 30;<br>
MyForm.AddNewEvent(testButton,tbeOnClick,'ButtonClicked');<br>
MyForm.Run;<br>
'''end;'''


'''Output:'''<br>
<b>Output:</b><br>
[[File:RadioButton.png|frameless|450px]]
[[File:RadioButton.png|frameless|450px]]<br>




= See Also =
<h2> See Also </h2>
* [[Components]]
* [[Object Properties]]
* [[Object Properties]]
* [[AddNewEvent]]
* [[AddNewEvent]]

Revision as of 10:26, 7 November 2024

AComponent : The variable name of the defined component is written. Here you should write the component variable name of whatever your component will be in.

xName : The name of the defined radio button should be written.

xCaption : You can add a title.

Radio buttons, also called option buttons, present a set of mutually exclusive choices. You can create individual radio buttons using TClRadioButton. A selected radio button is displayed as a circle filled in the middle. When not selected, the radio button shows an empty circle.


Feature Use of Definition
TclRadioButton RadioButton1 : TclRadioButton; A variable belonging to the TclRadioButton class is created.
AddNewRadioButton RadioButton1 = Form1.AddNewRadioButton(Form1,'RadioButton1','Test Radio Button Caption'); A new TclRadioButton is added to the form.
Width RadioButton1.Width = 150; Allows adjusting the width of the radioButton.
Height RadioButton1.Height = 50; Allows adjusting the height of the radioButton.
Align RadioButton1.Align = alTop; With the Align parameter, you can specify where you want our component to be aligned in the form. This parameter has multiple positioning properties. See the page to learn about these features.
Margins RadioButton1.Margins.Left = 50; // Right, Top, Bottom With the Margins parameter, you can give margins at any scale from the right, left, bottom, top.
TclRadioButtonMargins.png

Text RadioButton1.Text = 'RaidoButton's Text'; It represents the text within the component. The text entered by the user or set by the program is managed through this property.
TextSettings RadioButton1.StyledSettings = ssFamily;

RadioButton1.TextSettings.FontColor = clAlphaColor.clHexToColor('#8a067c');

RadioButton1.TextSettings.Font.Size = 20;

RadioButton1.TextSettings.Font.Style = [fsItalic]; //[fsItalic,fsUnderline]
Text formatting is performed in the component. To see the usage, see page.
isChecked RadioButton1.isChecked = True; Assign the value True or False to the Checked property to change the radio button's visual state. As soon as it is correct, it will come selected.

Example

Example let's put 2 radioButtons on the form. Here, when one is clicked and I click on the other, we will see that the clicked one is unticked. Now you can create a project with the options you want in the design you want with the radioButton.

 var
   MyForm:TclForm;
   testButton : TclButton;
   testRadio,testRadio2 : TClRadioButton;
 
 void ButtonClicked;
 {
   testRadio.isChecked =  not testRadio.isChecked;
 }
 
 {
   MyForm = TclForm.Create(Self);
   testButton= MyForm.AddNewButton(MyForm,'testButton','Click');
   testButton.TextSettings.Font.Size=50;
   testButton.Align = alCenter;
   testButton.Height = 50;
   testButton.Width = 100;
   
   testRadio = MyForm.AddNewRadioButton(MyForm,'testRadio','Female');
   testRadio.StyledSettings = ssFamily;
   testRadio.TextSettings.Font.Size=25;
   testRadio.TextSettings.FontColor = clAlphaColor.clHexToColor('#8a067c');
   testRadio.Align = alTop;
   testRadio.Height = 30;
   
   testRadio2 = MyForm.AddNewRadioButton(MyForm,'testRadio2','Male');
   testRadio2.StyledSettings = ssFamily;
   testRadio2.TextSettings.Font.Size=25;
   testRadio2.TextSettings.FontColor = clAlphaColor.clHexToColor('#8a067c');
   testRadio2.Align = alTop;
   testRadio2.Height = 30;
   
   MyForm.AddNewEvent(testButton,tbeOnClick,'ButtonClicked');
   
   MyForm.Run;
 }

Output:
RadioButton.png


See Also