From Clomosy Docs

No edit summary
No edit summary
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The TclLabel component is used to output a user-modifiable text (it can of course also be modified by a program).
<div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert">
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.<br>
function AddNewLabel(AComponent: TCLComponent; xName, xCaption: string): TclLabel;
</div>


AddNewLabel(TComponent, xName, xCaption): TclLabel
<span style="color:blue"><b>AComponent</b></span> : Specifies the parent of the object to be defined.<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 label should be written.<br>


<span style="color:blue">''xName''</span> : The name of the defined label should be written.
<span style="color:blue"><b>xCaption</b></span> : You can enter the chart title here.<br>


<span style="color:blue">''xCaption''</span> : You can enter the chart title here.
It creates a text label used to provide explanations or information in the user interface. TclLabel is preferred for labeling other components on the form or providing information to the user. For example, explanations such as "Username" or "Password" can be displayed next to an input field.<br>


Let's create a label.<br>
The features and usage are provided in the table below.<br>


1. Create a new project.<br>
<div class="table-responsive">
{| class="wikitable" style="border: 2px solid #c3d7e0"
! style="background-color: #c3d7e0"| Feature  !!style="background-color: #c3d7e0"| Use of !!style="background-color: #c3d7e0"| Definition
|-
|TclLabel || Label1 : TclLabel;  || A variable belonging to the TclLabel class is created.
|-
|AddNewLabel || Label1 = MyForm.AddNewLabel(MyForm,'Label1','Test Label Caption'); || A new TclLabel is added to the form.
|-
|Width || Label1.Width = 150; ||Allows adjusting the width of the label.
|-
|Height || Label1.Height = 50; ||Allows adjusting the height of the label.
|-
|Align  || Label1.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.
|-
|Margins || Label1.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:TclLabelMargins.png|frameless|200px]]<br><br>
|-
|TextSettings || Label1.StyledSettings = ssFamily;<br>Label1.TextSettings.FontColor = clAlphaColor.clHexToColor('#8a067c');<br>Label1.TextSettings.Font.Size = 20;<br>Label1.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].
|-
|Text  || Label1.Text = 'Label'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.
|-
|Caption ||Label1.Caption = 'Button Caption'; || It represents the text displayed on the component. The Caption specifies the textual label that the component presents to the user.
|}
</div>


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.<br>
'''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.<br>


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.
<b>Example</b><br>
<span style="color:blue">testLayout</span> := MyForm.AddNewLayout(MyForm,'testLayout');
<pre>
testLabel:= MyForm.AddNewLabel(<span style="color:blue">testLayout</span>,'testLabel','Test Label Caption');
  var
 
  MyForm:TclForm;
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.<br>
  testLabel : TclLabel;
   
[[File:ShortcutDefinition.png|frameless|400px]]<br><br>
 
As soon as you click, the following block will come automatically.<br>
 
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',<nowiki>''</nowiki>);
  {
 
  MyForm = TclForm.Create(Self);
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= MyForm.AddNewLabel(MyForm,'testLabel','Test Label Caption');
  testLabel.StyledSettings = ssFamily;
testLabel.Caption := 'Label Caption';
  testLabel.TextSettings.Font.Size=20;
 
  testLabel.Align = alCenter;
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.Margins.Left= 50;
 
  testLabel.Margins.Top= 10;  
testLabel.Text := 'Label's Text';
  testLabel.Height = 50;
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.Width = 150;
 
 
testLabel.Text := testEdit.Text;
  MyForm.Run;
ShowMessage(testLabel.Text);
  }
 
</pre>
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 [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".
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;
 
[[File:TclLabelMargins.png|frameless|500px]]<br><bR>
 
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.<br>
testLabel.StyledSettings := ssFamily;
To adjust the text size;<br>
  testLabel.TextSettings.Font.Size := 20;
To set the text color;<br>
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:<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>
<b>Output:</b><br>
'''var'''
[[File:Label.png|frameless|450px]]<br>
MyForm:TFrmClomosyBasisForm;
testLabel : TclLabel;<br>
'''begin'''<br>
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;<br>
MyForm.Run;<br>
'''end;'''
'''Output:'''<br>
[[File:Label.png|frameless|450px]]


= See Also =
<h2> See Also </h2>
* [[Components]]
* [[Object Properties]]
* [[Object Properties]]
* [[AddNewEvent]]
* [[AddNewEvent]]
{{#seo:|title=TclLabel Using in Clomosy- Clomosy Docs}}
{{#seo:|description=TclLabel creates text labels for UI, perfect for labeling components or displaying information like 'Username' or 'Password' near input fields.}}

Latest revision as of 11:55, 8 January 2025

AComponent : Specifies the parent of the object to be defined.

xName : The name of the defined label should be written.

xCaption : You can enter the chart title here.

It creates a text label used to provide explanations or information in the user interface. TclLabel is preferred for labeling other components on the form or providing information to the user. For example, explanations such as "Username" or "Password" can be displayed next to an input field.

The features and usage are provided in the table below.

Feature Use of Definition
TclLabel Label1 : TclLabel; A variable belonging to the TclLabel class is created.
AddNewLabel Label1 = MyForm.AddNewLabel(MyForm,'Label1','Test Label Caption'); A new TclLabel is added to the form.
Width Label1.Width = 150; Allows adjusting the width of the label.
Height Label1.Height = 50; Allows adjusting the height of the label.
Align Label1.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 Label1.Margins.Left = 50; // Right, Top, Bottom With the Margins parameter, you can give margins at any scale from the right, left, bottom, top.
TclLabelMargins.png

TextSettings Label1.StyledSettings = ssFamily;
Label1.TextSettings.FontColor = clAlphaColor.clHexToColor('#8a067c');
Label1.TextSettings.Font.Size = 20;
Label1.TextSettings.Font.Style = [fsItalic]; //[fsItalic,fsUnderline]
Text formatting is performed in the component. To see the usage, see page.
Text Label1.Text = 'Label'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.
Caption Label1.Caption = 'Button Caption'; It represents the text displayed on the component. The Caption specifies the textual label that the component presents to the user.



Example

 var
   MyForm:TclForm;
   testLabel : TclLabel;
 
 {
   MyForm = TclForm.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;
 }


Output:
Label.png

See Also