From Clomosy Docs
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
<div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert"> | |||
function AddNewButton(AComponent: TCLComponent; xName, xCaption: string): TclButton; | |||
</div> | |||
<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"> | <span style="color:blue"><b>xName</b></span> : The name of the defined button should be written.<br> | ||
<span style="color:blue"> | <span style="color:blue"><b>xCaption</b></span> : You can add a title.<br> | ||
It is a component used to perform a specific action in the user interface. When a button is placed on the form, it allows the user to trigger a particular function by clicking it. For example, a "Save" button can be added to allow data to be saved.<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 | ||
|- | |- | ||
|TClButton || Button1 : TclButton; || A variable belonging to the TclButton class is created. | |TClButton || Button1 : TclButton; || A variable belonging to the TclButton class is created. | ||
|- | |- | ||
|AddNewButton || Button1 = | |AddNewButton || Button1 = Form1.AddNewButton(Form1,'Button1','Test Button Caption'); || A new TclButton is added to the form. | ||
|- | |- | ||
|Width || Button1.Width = 150; ||Allows adjusting the width of the button. | |Width || Button1.Width = 150; ||Allows adjusting the width of the button. | ||
| Line 30: | Line 33: | ||
|TextSettings || Button1.StyledSettings = ssFamily;<br><br>Button1.TextSettings.FontColor = clAlphaColor.clHexToColor('#8a067c');<br><br>Button1.TextSettings.Font.Size = 20;<br><br>Button1.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]. | |TextSettings || Button1.StyledSettings = ssFamily;<br><br>Button1.TextSettings.FontColor = clAlphaColor.clHexToColor('#8a067c');<br><br>Button1.TextSettings.Font.Size = 20;<br><br>Button1.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]. | ||
|} | |} | ||
</div> | |||
<b>Example</b><br> | |||
<pre> | |||
var | |||
MyForm:TclForm; | |||
testButton : TclButton; | |||
{ | |||
MyForm = TclForm.Create(Self); | |||
testButton= MyForm.AddNewButton(MyForm,'testButton','Click'); | |||
testButton.TextSettings.Font.Size=50; | |||
testButton.Align = alCenter; | |||
testButton.Height = 50; | |||
testButton.Width = 100; | |||
MyForm.AddNewEvent(testButton,tbeOnClick,'ShowMessage(''Hello'');'); | |||
MyForm.Run; | |||
} | |||
</pre> | |||
<b>Output:</b><br> | |||
[[File:Button.png|frameless|450px]]<br> | |||
<h2> See Also </h2> | |||
[[ | * [[Components]] | ||
* [[Object Properties]] | |||
* [[AddNewEvent]] | |||
Revision as of 08:17, 7 November 2024
function AddNewButton(AComponent: TCLComponent; xName, xCaption: string): TclButton;
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 button should be written.
xCaption : You can add a title.
It is a component used to perform a specific action in the user interface. When a button is placed on the form, it allows the user to trigger a particular function by clicking it. For example, a "Save" button can be added to allow data to be saved.
| Feature | Use of | Definition |
|---|---|---|
| TClButton | Button1 : TclButton; | A variable belonging to the TclButton class is created. |
| AddNewButton | Button1 = Form1.AddNewButton(Form1,'Button1','Test Button Caption'); | A new TclButton is added to the form. |
| Width | Button1.Width = 150; | Allows adjusting the width of the button. |
| Height | Button1.Height = 50; | Allows adjusting the height of the button. |
| Align | Button1.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 | Button1.Margins.Left = 50; // Right, Top, Bottom | With the Margins parameter, you can give margins at any scale from the right, left, bottom, top. |
| Caption | Button1.Caption = 'Button Caption'; | It represents the text displayed on the component. The Caption specifies the textual label that the component presents to the user. |
| Text | Button1.Text = 'Button'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 | Button1.StyledSettings = ssFamily; Button1.TextSettings.FontColor = clAlphaColor.clHexToColor('#8a067c'); Button1.TextSettings.Font.Size = 20; Button1.TextSettings.Font.Style = [fsItalic]; //[fsItalic,fsUnderline] |
Text formatting is performed in the component. To see the usage, see page. |
Example
var
MyForm:TclForm;
testButton : TclButton;
{
MyForm = TclForm.Create(Self);
testButton= MyForm.AddNewButton(MyForm,'testButton','Click');
testButton.TextSettings.Font.Size=50;
testButton.Align = alCenter;
testButton.Height = 50;
testButton.Width = 100;
MyForm.AddNewEvent(testButton,tbeOnClick,'ShowMessage(''Hello'');');
MyForm.Run;
}
