From Clomosy Docs

No edit summary
No edit summary
Line 9: Line 9:
<span style="color:blue"> xCaption</span> : You can add a title.
<span style="color:blue"> xCaption</span> : You can add a title.


Let's create a radio button.<br>
{| class="wikitable" style="border: 2px solid #c3d7e0"
 
! style="background-color: #c3d7e0"| Feature !!style="background-color: #c3d7e0"| Use of !!style="background-color: #c3d7e0"|Definition
1. Create a new project.<br>
|-
 
|TclRadioButton || RadioButton1 : TclRadioButton; || A variable belonging to the TclRadioButton class is created.
2. You need to define TclRadioButton on the form. To do this, you should add under the ''var'' parameter on the ide as follows. It is the name of your variable you typed at the beginning. You should define this as you want and add it as TClRadioButton.<br>
|-
'''var'''
|AddNewRadioButton || RadioButton1 = MyForm.AddNewRadioButton(MyForm,'RadioButton1','Test Radio Button Caption'); || A new TclRadioButton is added to the form.
testRadio : TclRadioButton;
|-
 
|Width || RadioButton1.Width = 150; ||Allows adjusting the width of the radioButton.
3. Add the TclRadioButton to the form. For this, you must add the begin end block and add it inside the form after the form is defined. By saying MyForm.AddNewRadioButton, we actually add to the form we have defined. Here, you need to add your form definition as whatever you wrote it.<br>
|-
 
|Height || RadioButton1.Height = 50; ||Allows adjusting the height of the radioButton.
testRadio := ''MyForm''.AddNewRadioButton(MyForm,'testRadio','Test Radio Button Caption');
|-
 
|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 [[Object_Properties#Align | page]] to learn about these features.
4. If you do not want to define it in the form, you can add it in another component (such as Layout, Panel). Of course, before that, that component must be defined.
|-
<span style="color:blue">testLayout</span> := MyForm.AddNewLayout(MyForm,'testLayout');
|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.<br>[[File:TclRadioButtonMargins.png|frameless|200px]]<br><br>
testRadio := MyForm.AddNewRadioButton(<span style="color:blue">testLayout</span>,'testRadio','Test Radio Button Caption');
|-
 
|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.
5. We gave the variable name while defining the TclRadioButton in var. Now when you add this in begin end you should use this variable name in all definitions. Your code will throw an error when you write these variable names incorrectly.
|-
 
|TextSettings || RadioButton1.StyledSettings = ssFamily;<br><br>RadioButton1.TextSettings.FontColor = clAlphaColor.clHexToColor('#8a067c');<br><br>RadioButton1.TextSettings.Font.Size = 20;<br><br>RadioButton1.TextSettings.Font.Style = [fsItalic]; //[fsItalic,fsUnderline] || Text formatting is performed in the component. To see the usage, see [https://www.docs.clomosy.com/index.php/Object_Properties#Text_Settings page].
6. You give a title to your Radio Button component as the last parameter when defining your project. This title is the text that will appear on the screen when the application is run. You may not want to write this title while defining it.
|-
|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.
testRadio := ''MyForm''.AddNewRadioButton(MyForm,'testRadio',<nowiki>''</nowiki>);
|}
 
7. Another use of Radio Button is to add text. If we add text to our component by saying radioButton.text, when the project is run, the title does not appear and the value you have written in the text starts to appear.
 
testRadio.Text := 'RaidoButton's Text';
For example, take the value written in an TclEdit component and put it in the radio button and show me this. Below we show you how to do this.
 
testRadio.Text := testEdit.Text;
ShowMessage(testRadio.Text);
 
8. Now let's design our TclRadioButton component. Let's set the width and height first. For this, you must make the following definitions.
 
  testRadio.Height := 50;
testRadio.Width := 150;
 
9. 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 [https://www.docs.clomosy.com/index.php/Object_Properties#Align page] to learn about these features. We're going to call it the top part here. So we have to write "AlTop".
testRadio.Align := alTop;
 
10. With the Margins parameter, you can give margins at any scale from the right, left, bottom, top.
 
testRadio.Margins.Left:= 50;
testRadio.Margins.Right:= 10;
testRadio.Margins.Top:= 50;
testRadio.Margins.Bottom:= 10;
 
[[File:TclRadioButtonMargins.png|frameless|400px]]<br><br>
 
As seen in the example above, you do not need to set margins for every field. For example, it didn't make any sense to give us the "Bottom" and "Right" aspects here. Because we have positioned our component on the top and left side here, and we have given spaces to prevent it from sticking to the edges.
 
 
11. You may want to change the appearance of the text in the tag. We will use the TextSettings parameter for this.In order to use this parameter, you have to make the following definition. Otherwise your commands will not work.<br>
testRadio.StyledSettings := ssFamily;
To adjust the text size;<br>
testRadio.TextSettings.Font.Size := 20;
To set the text color;<br>
testRadio.TextSettings.FontColor := clAlphaColor.clHexToColor('#8a067c');
 
12. 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.<br>
'''Use Of:'''<br>
testRadio.isChecked := True;
 
13. To tell you the truth, you have created a simple application that does nothing yet. Let's save and start using our project. You can save in one of two ways:<br>
Click the save icon (the button in the upper right corner) or press Ctrl + S to save the project and see what you've done on the platforms now.
 


'''Example:'''<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>
:'''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;'''


:'''TRObject Syntax'''
:'''TRObject Syntax'''
Line 147: Line 72:
     MyForm.Run;
     MyForm.Run;
   }
   }
:'''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>
'''Output:'''<br>

Revision as of 06:41, 23 August 2024

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.

AddNewRadioButton(TComponent, xName, xCaption): TclRadioButton

TComponent : 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.

Feature Use of Definition
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.
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.

TRObject Syntax
 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;
 }
Base Syntax
var
MyForm:TclForm;
testButton : TclButton;
testRadio,testRadio2 : TClRadioButton;
procedure ButtonClicked; begin testRadio.isChecked := not testRadio.isChecked; end;
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;
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;
end;

Output:
RadioButton.png


See Also