From Clomosy Docs
CheckBox represents a TclCheckBox style checkbox that can be open (selected) or closed (cleared). The CheckBox component gives you a choice. Select the box to turn the option on or clear the box to turn the option off.
AddNewCheckBox(TComponent, xName, xCaption): TclCheckBox
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 chechbox should be written.
xCaption : You can add a title.
Let's create a checkbox.
1. Create a new project.
2. You need to define TclCheckBox 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 TclCheckBox.
var testCheckBox : TclCheckBox;
3. Add the TclCheckBox 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.AddNewCheckBox, we actually add to the form we have defined. Here, you need to add your form definition as whatever you wrote it.
testCheckBox := MyForm.AddNewCheckBox(MyForm,'testCheckBox','Test CheckBox Caption');
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.
testLayout := MyForm.AddNewLayout(MyForm,'testLayout'); testCheckBox := MyForm.AddNewCheckBox(testLayout,'testCheckBox','Test CheckBox Caption');
5. While defining the component, you can define it manually by typing. Another method is to write its shortcut. If you type "AddNewCheckBox" while the shortcut is in the code block, a pop-up menu will appear.
6. We gave the variable name while defining the TclCheckBox 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.
7. You give a title to your Checkbox 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.
testCheckBox := MyForm.AddNewCheckBox(MyForm,'testCheckBox','');
8. Another use of Checkbox is to add text. If we add text to our component by saying testCheckBox.text, when the project is run, the title does not appear and the value you have written in the text starts to appear.
testCheckBox.Text := 'CheckBox's Text';
For example, take the value written in an TclEdit component and put it in the checkbox and show me this. Below we show you how to do this.
testCheckBox.Text := testEdit.Text; ShowMessage(testCheckBox.Text);
9. Now let's design our TclCheckBox component. Let's set the width and height first. For this, you must make the following definitions.
testCheckBox.Height := 50; testCheckBox.Width := 150;
10. 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. We're going to call it the top part here. So we have to write "AlTop".
testCheckBox.Align := alTop;
11. With the Margins parameter, you can give margins at any scale from the right, left, bottom, top.
testCheckBox.Margins.Left:= 50; testCheckBox.Margins.Right:= 10; testCheckBox.Margins.Top:= 50; testCheckBox.Margins.Bottom:= 10;
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.
12. 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.
testCheckBox.StyledSettings := ssFamily;
To adjust the text size;
testCheckBox.TextSettings.Font.Size := 20;
To set the text color;
testCheckBox.TextSettings.FontColor := clAlphaColor.clHexToColor('#8a067c');
13. Assign the value True or False to the Checked property to change the checkBox's visual state. As soon as it is correct, it will come selected.
Use Of:
testCheckBox.isChecked := True;
14. 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:
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:
var MyForm:TclForm; testButton : TclButton; testLabel : TclLabel; testCheckBox,testCheckBox2 : TClCheckBox;
procedure ButtonClicked; begin testCheckBox.isChecked := not testCheckBox.isChecked; testCheckBox2.isChecked := not testCheckBox2.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;
testLabel := MyForm.AddNewLabel(MyForm,'testLabel','Your hobbies?'); testLabel.StyledSettings := ssFamily; testLabel.TextSettings.Font.Size:=25; testLabel.TextSettings.FontColor := clAlphaColor.clHexToColor('#4a08ff'); testLabel.Align := alMostTop; testLabel.Height := 30;
testCheckBox := MyForm.AddNewCheckBox(MyForm,'testCheckBox','Reading book'); testCheckBox.StyledSettings := ssFamily; testCheckBox.TextSettings.Font.Size:=15; testCheckBox.TextSettings.FontColor := clAlphaColor.clHexToColor('#272643'); testCheckBox.Align := alTop; testCheckBox.Height := 30;
testCheckBox2 := MyForm.AddNewCheckBox(MyForm,'testCheckBox2','Watching movie'); testCheckBox2.StyledSettings := ssFamily; testCheckBox2.TextSettings.Font.Size:=15; testCheckBox2.TextSettings.FontColor := clAlphaColor.clHexToColor('#272643'); testCheckBox2.Align := alTop; testCheckBox2.Height := 30;
MyForm.AddNewEvent(testButton,tbeOnClick,'ButtonClicked');
MyForm.Run; end;

