From Clomosy Docs

Revision as of 14:03, 22 August 2024 by ClomosyManager (talk | contribs)

A TclButton is a general-purpose push button for use in applications. When the button is clicked, we can navigate to a function, procedure or activate other actions.

AddNewButton(xOwner:TComponent; xName,xCaption:String): TClButton

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 button should be written.

xCaption : You can add a title.

Feature Use of Definition
TClButton Button1 : TclButton; A variable belonging to the TclButton class is created.
AddNewButton Button1 = MyForm.AddNewButton(MyForm,'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.
TclButtonMargins.png

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:

TRObject Syntax
 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;
 
 }
Base Syntax
 var
   MyForm:TclForm;
   testButton : TclButton;
 
 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;
   
   MyForm.AddNewEvent(testButton,tbeOnClick,'ShowMessage(''Hello'');');
   
   MyForm.Run;
 
 end;

Output:
Button.png