From Clomosy Docs
No edit summary |
No edit summary |
||
| Line 8: | Line 8: | ||
<span style="color:blue">''xName''</span> : The name of the defined label should be written. | <span style="color:blue">''xName''</span> : The name of the defined label should be written. | ||
<span style="color:blue">''xCaption''</span> : You can | <span style="color:blue">''xCaption''</span> : You can enter the chart title here. | ||
Let's create a label.<br> | Let's create a label.<br> | ||
| Line 76: | Line 76: | ||
testLabel.TextSettings.FontColor := clAlphaColor.clHexToColor('#8a067c'); | testLabel.TextSettings.FontColor := clAlphaColor.clHexToColor('#8a067c'); | ||
14. To tell you the truth, you have created a simple application that does nothing yet. You can | 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:<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. | |||
Revision as of 08:24, 15 March 2023
The TclLabel component is used to output a user-modifiable text (it can of course also be modified by a program).
Tags display text. You place a label on a form when you need to define or annotate another component, such as an edit box, or when you want to add text to the form. The standard label component TclLabel is a windowless control. Tags typically display read-only static text that cannot be changed by the application user.
AddNewLabel(TComponent, xName, xCaption): TclLabel
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 label should be written.
xCaption : You can enter the chart title here.
Let's create a label.
1. Create a new project.
2. You need to define TclLabel 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 TclLabel.
var testLabel : TclLabel;
3. Add the TclLabel 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.AddNewLabel, we actually add to the form we have defined. Here, you need to add your form definition as whatever you wrote it.
testLabel:= MyForm.AddNewLabel(MyForm,'testLabel','Test Label 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'); testLabel:= MyForm.AddNewLabel(testLayout,'testLabel','Test Label Caption');
5. While defining the component, you can define it manually by typing. Another method is to write its shortcut. If you type "AddNewLabel" while the shortcut is in the code block, a pop-up menu will appear.
As soon as you click, the following block will come automatically.
AddNewLabel(xOwner:TComponent; xName,xCaption:String);
6. We gave the variable name while defining the TclLabel 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 Label 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.
testLabel:= MyForm.AddNewLabel(MyForm,'testLabel','');
8. Then you can make a definition as follows. Well, an external title can be entered so that it does not appear empty when this project is run. For this, a title can be added with label.Caption assignment.
testLabel.Caption := 'Label Caption';
9. Another use of Label is to add text. If we add text to our component by saying label.text, when the project is run, the title does not appear and the value you have written in the text starts to appear.
testLabel.Text := 'Label's Text';
For example, take the value written in an TClEdit component and put it in the label and show me this. Below we show you how to do this.
testLabel.Text := testEdit.Text; ShowMessage(testLabel.Text);
10. Now let's design our TclLabel component. Let's set the width and height first. For this, you must make the following definitions.
testLabel.Height := 50; testLabel.Width := 150;
11. 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".
testLabel.Align := alTop;
12. With the Margins parameter, you can give margins at any scale from the right, left, bottom, top.
testLabel.Margins.Left:= 50; testLabel.Margins.Right:= 10; testLabel.Margins.Top:= 50; testLabel.Margins.Bottom:= 10;
13. 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.
testLabel.StyledSettings := ssFamily;
To adjust the text size;
testLabel.TextSettings.Font.Size := 20;
To set the text color;
testLabel.TextSettings.FontColor := clAlphaColor.clHexToColor('#8a067c');
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:TFrmClomosyBasisForm; testLabel : TclLabel;
begin
MyForm := TFrmClomosyBasisForm.Create(Self); testLabel:= MyForm.AddNewLabel(MyForm,'testLabel','Test Label Caption'); testLabel.StyledSettings := ssFamily; testLabel.TextSettings.Font.Size:=20; testLabel.Align := alCenter; testLabel.Margins.Left:= 50; testLabel.Margins.Top:= 10; testLabel.Height := 50; testLabel.Width := 150;
MyForm.Run;
end;

