From Clomosy Docs

Revision as of 08:26, 15 March 2023 by ClomosyManager (talk | contribs)

You can add text input field with "TclEdit". Let's see how it is defined.

AddNewEdit(TComponent, xName, xPromptText)

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

xPromptText : A hint or message to be displayed when the Text property is empty.

Let's create a edit.

1. Create a new project.

2. You need to define TclEdit 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 TclEdit.

var
testEdit : TclEdit; 

3. Add the TclEdit 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.AddNewEdit, we actually add to the form we have defined. Here, you need to add your form definition as whatever you wrote it.

testEdit := MyForm.AddNewEdit(MyForm,'testEdit','Test Edit Message');

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');
testEdit := MyForm.AddNewEdit(testLayout,'testEdit','Test Edit Message');

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.

TclEditShortcut.png

As soon as you click, the following block will come automatically.

AddNewEdit(xOwner:TComponent; xName,xPromptText:String);

6. We gave the variable name while defining the TclEdit 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 can print a message to your Edit 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 when defining this title. An empty edit will appear on the screen.

testEdit := MyForm.AddNewEdit(MyForm,'testEdit','');

10. Now let's design our TclEdit component. Let's set the width and height first. For this, you must make the following definitions.

testEdit.Height := 50;
testEdit.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".

testEdit.Align := alTop;

12. With the Margins parameter, you can give margins at any scale from the right, left, bottom, top.

testEdit.Margins.Left:= 100;
testEdit.Margins.Right:= 100; 
testEdit.Margins.Top:= 100;
testEdit.Margins.Bottom:= 10;

TclEditMargins.png

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.

testEdit.StyledSettings := ssFamily;

To adjust the text size;

testEdit.TextSettings.Font.Size := 20;

To set the text color;

testEdit.TextSettings.FontColor := clAlphaColor.clHexToColor('#8a067c');

14. When you click on Edit, you can write all the characters you want in a text (such as numbers, symbols, letters). You can restrict the characters you can write in the text. So how will you do this?
You can do this with the "clTypeOfField" command below. You can define this command as "taFloat - taDate - taString".

testEdit.clTypeOfField := taFloat;

What do these mean?

taFloat : Only numbers and comma characters can be written.

taString : All characters can be written. (numbers, symbols, letters)


15. 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;
testEdit : TclEdit;
begin MyForm := TFrmClomosyBasisForm.Create(Self); testEdit:= MyForm.AddNewEdit(MyForm,'testEdit','Write something'); testEdit.TextSettings.Font.Size:=70; testEdit.Align := alTop; testEdit.Margins.Top:= 10; testEdit.Height := 50; testEdit.Width := 150;
MyForm.Run;
end;

Output:
Edit.png