From Clomosy Docs

No edit summary
No edit summary
Line 10: Line 10:
:'''Base Syntax'''
:'''Base Syntax'''


Var   
  Var   
  MyForm:TclForm;
  MyForm:TclForm;
  mainPnl : TclProPanel;
  mainPnl : TclProPanel;
  testBtn : TClProButton;
  testBtn : TClProButton;
  i : Integer;
  i : Integer;
  objectName:string;
  objectName:string;
 
  procedure GetName(getObject:String);
  procedure GetName;
  var
    clickedBtn:TClProButton;
  begin
    clickedBtn := TClProButton(Myform.Clsender);
    TClProButton(MyForm.clFindComponent(clickedBtn.Caption)).Caption := clickedBtn.Caption+'+';
    clickedBtn.Enabled := false;
  end;
 
   begin
   begin
    TClProButton(MyForm.clFindComponent(getObject)).Caption := objectName+'+';
  MyForm:=TclForm.Create(self);
  end;
  mainPnl:=MyForm.AddNewProPanel(MyForm,'mainPnl');
  clComponent.SetupComponent(mainPnl,'{"Align" : "Center","Width" :200,  
  procedure BtnOnClick;
  "Height":300,"RoundHeight":10,"RoundWidth":10,"BorderColor":"#3a32a8","BorderWidth":2}');
  begin
 
    objectName := TClProButton(Myform.Clsender).Caption;
  for i := 0 to 4 do
    GetName(objectName);
  begin
  end;
  testBtn := MyForm.AddNewProButton(mainPnl,'testBtn'+IntToStr(i+1),<nowiki>''</nowiki>);
  clComponent.SetupComponent(testBtn,'{"caption":"testBtn'+IntToStr(i+1)+'","Align" : "Top","MarginTop":5,"MarginLeft":5,"MarginRight":5,
begin
  "Height":50}');
  MyForm:=TclForm.Create(self);
  MyForm.SetImage(testBtn,'https://clomosy.com/demos/foodInformationBox.png');  
  mainPnl:=MyForm.AddNewProPanel(MyForm,'mainPnl');
   
  clComponent.SetupComponent(mainPnl,'{"Align" : "Center","Width" :200,  
    MyForm.AddNewEvent(testBtn,tbeOnClick,'GetName');
"Height":300,"RoundHeight":10,"RoundWidth":10,"BorderColor":"#3a32a8","BorderWidth":2}');
  end;
 
  for i := 0 to 4 do
  MyForm.Run;
  begin
  testBtn := MyForm.AddNewProButton(mainPnl,'testBtn'+IntToStr(i+1),<nowiki>''</nowiki>);
  clComponent.SetupComponent(testBtn,'{"caption":"testBtn'+IntToStr(i+1)+'","Align" : "Top","MarginTop":5,"MarginLeft":5,"MarginRight":5,
  "Height":50}');
MyForm.SetImage(testBtn,'https://clomosy.com/demos/foodInformationBox.png');  
  MyForm.AddNewEvent(testBtn,tbeOnClick,'BtnOnClick');
   end;
   end;
  MyForm.Run;
end;


:'''TRObject Syntax:'''
:'''TRObject Syntax:'''


Var   
  Var   
  MyForm:TclForm;
  MyForm:TclForm;
  mainPnl : TclProPanel;
  mainPnl : TclProPanel;
  testBtn : TClProButton;
  testBtn : TClProButton;
  i : Integer;
  i : Integer;
  objectName:string;
  objectName:string;
 
  void GetName(getObject:String);
  void GetName;
  var
    clickedBtn:TClProButton;
  {
    clickedBtn = TClProButton(Myform.Clsender);
    TClProButton(MyForm.clFindComponent(clickedBtn.Caption)).Caption = clickedBtn.Caption+'+';
    clickedBtn.Enabled = false;
  }
 
   {
   {
    TClProButton(MyForm.clFindComponent(getObject)).Caption = objectName+'+';
  MyForm=TclForm.Create(self);
  }
  mainPnl=MyForm.AddNewProPanel(MyForm,'mainPnl');
  clComponent.SetupComponent(mainPnl,'{"Align" : "Center","Width" :200,  
  void BtnOnClick;
  "Height":300,"RoundHeight":10,"RoundWidth":10,"BorderColor":"#3a32a8","BorderWidth":2}');
  {
 
    objectName = TClProButton(Myform.Clsender).Caption;
  for (i = 0 to 4)
    GetName(objectName);
  {
  }
  testBtn = MyForm.AddNewProButton(mainPnl,'testBtn'+IntToStr(i+1),<nowiki>''</nowiki>);
  clComponent.SetupComponent(testBtn,'{"caption":"testBtn'+IntToStr(i+1)+'","Align" : "Top","MarginTop":5,"MarginLeft":5,"MarginRight":5,
{
  "Height":50}');
  MyForm=TclForm.Create(self);
  MyForm.SetImage(testBtn,'https://clomosy.com/demos/foodInformationBox.png');  
  mainPnl=MyForm.AddNewProPanel(MyForm,'mainPnl');
   
  clComponent.SetupComponent(mainPnl,'{"Align" : "Center","Width" :200,  
    MyForm.AddNewEvent(testBtn,tbeOnClick,'GetName');
"Height":300,"RoundHeight":10,"RoundWidth":10,"BorderColor":"#3a32a8","BorderWidth":2}');
  }
  for (i = 0 to 4)
  {
  testBtn = MyForm.AddNewProButton(mainPnl,'testBtn'+IntToStr(i+1),<nowiki>''</nowiki>);
clComponent.SetupComponent(testBtn,'{"caption":"testBtn'+IntToStr(i+1)+'","Align" : "Top","MarginTop":5,"MarginLeft":5,"MarginRight":5,
  "Height":50}');
MyForm.SetImage(testBtn,'https://clomosy.com/demos/foodInformationBox.png');  
    
    
   MyForm.AddNewEvent(testBtn,tbeOnClick,'BtnOnClick');
   MyForm.Run;
   }
   }
 
  MyForm.Run;
}


= See Also=
= See Also=
* [[Controls| Controls]]
* [[Controls| Controls]]

Revision as of 08:53, 13 February 2024

To find another component under a component or form, clFindComponent is used. This method allows you to search for a specific named subcomponent. This allows making changes to the properties of the found component.

MyForm.clFindComponent(xObjectName : String)

Within this feature, a string parameter is accepted, and this parameter is the name of the variable.

Example:
In the example, we can determine which of the multiple buttons created using the clSender feature we clicked on and change the button text using the clFindComponent property.

Base Syntax
 Var  
  MyForm:TclForm;
  mainPnl : TclProPanel;
  testBtn : TClProButton;
  i : Integer;
  objectName:string;
 
  procedure GetName;
  var
    clickedBtn:TClProButton;
  begin
    clickedBtn := TClProButton(Myform.Clsender);
    TClProButton(MyForm.clFindComponent(clickedBtn.Caption)).Caption := clickedBtn.Caption+'+';
    clickedBtn.Enabled := false;
  end;
 
 begin
  MyForm:=TclForm.Create(self);
  mainPnl:=MyForm.AddNewProPanel(MyForm,'mainPnl');
  clComponent.SetupComponent(mainPnl,'{"Align" : "Center","Width" :200, 
 "Height":300,"RoundHeight":10,"RoundWidth":10,"BorderColor":"#3a32a8","BorderWidth":2}');
 
  for i := 0 to 4 do
  begin
  testBtn := MyForm.AddNewProButton(mainPnl,'testBtn'+IntToStr(i+1),'');
 clComponent.SetupComponent(testBtn,'{"caption":"testBtn'+IntToStr(i+1)+'","Align" : "Top","MarginTop":5,"MarginLeft":5,"MarginRight":5,
  "Height":50}');
 MyForm.SetImage(testBtn,'https://clomosy.com/demos/foodInformationBox.png'); 
   
   MyForm.AddNewEvent(testBtn,tbeOnClick,'GetName');
  end;
  
  MyForm.Run;
 end;
TRObject Syntax:
 Var  
  MyForm:TclForm;
  mainPnl : TclProPanel;
  testBtn : TClProButton;
  i : Integer;
  objectName:string;
 
  void GetName;
  var
    clickedBtn:TClProButton;
  {
    clickedBtn = TClProButton(Myform.Clsender);
    TClProButton(MyForm.clFindComponent(clickedBtn.Caption)).Caption = clickedBtn.Caption+'+';
    clickedBtn.Enabled = false;
  }
 
 {
  MyForm=TclForm.Create(self);
  mainPnl=MyForm.AddNewProPanel(MyForm,'mainPnl');
  clComponent.SetupComponent(mainPnl,'{"Align" : "Center","Width" :200, 
 "Height":300,"RoundHeight":10,"RoundWidth":10,"BorderColor":"#3a32a8","BorderWidth":2}');
 
  for (i = 0 to 4)
  {
  testBtn = MyForm.AddNewProButton(mainPnl,'testBtn'+IntToStr(i+1),'');
 clComponent.SetupComponent(testBtn,'{"caption":"testBtn'+IntToStr(i+1)+'","Align" : "Top","MarginTop":5,"MarginLeft":5,"MarginRight":5,
  "Height":50}');
 MyForm.SetImage(testBtn,'https://clomosy.com/demos/foodInformationBox.png'); 
   
   MyForm.AddNewEvent(testBtn,tbeOnClick,'GetName');
  }
  
  MyForm.Run;
 }

See Also