From Clomosy Docs
No edit summary |
No edit summary |
||
| Line 18: | Line 18: | ||
After creating the definitions, when the button is clicked, a procedure should go and read the barcode in this procedure and write the barcode code in the edit. For this we need to define the following code.<br> | After creating the definitions, when the button is clicked, a procedure should go and read the barcode in this procedure and write the barcode code in the edit. For this we need to define the following code.<br> | ||
<blockquote style="background-color:#F7F5EB"> | <blockquote style="background-color:#F7F5EB"> | ||
''' | '''void''' BtnOnClick;<br> | ||
''' | '''{'''<br> | ||
MyForm.'''CallBarcodeReader'''(testEdit);<br> | MyForm.'''CallBarcodeReader'''(testEdit);<br> | ||
''' | '''}''' | ||
</blockquote> | </blockquote> | ||
Now that the definitions and procedure have been created, let's start coding. Let's define our form. | Now that the definitions and procedure have been created, let's start coding. Let's define our form. | ||
<blockquote style="background-color:#F7F5EB"> | <blockquote style="background-color:#F7F5EB"> | ||
MyForm | MyForm = TclForm.Create(Self); | ||
</blockquote> | </blockquote> | ||
Then, let's make the settings of the variable we defined as "testEdit" to show the barcode code on the screen after the barcode is read. So let's create it by saying "AddNewEdit" and then determine its position and height. Let's assign its position to the top of our screen by saying "alTop". <br> | Then, let's make the settings of the variable we defined as "testEdit" to show the barcode code on the screen after the barcode is read. So let's create it by saying "AddNewEdit" and then determine its position and height. Let's assign its position to the top of our screen by saying "alTop". <br> | ||
<blockquote style="background-color:#F7F5EB"> | <blockquote style="background-color:#F7F5EB"> | ||
testEdit | testEdit = MyForm.AddNewEdit(MyForm,'testEdit','Barcode here ...');<br> | ||
testEdit.Align | testEdit.Align = alTop;<br> | ||
testEdit.Height | testEdit.Height = 40;<br> | ||
</blockquote> | </blockquote> | ||
Let's define our button and create its design. In order for it to be in the middle of our screen, we need to define it as "alCenter".<br> | Let's define our button and create its design. In order for it to be in the middle of our screen, we need to define it as "alCenter".<br> | ||
<blockquote style="background-color:#F7F5EB"> | <blockquote style="background-color:#F7F5EB"> | ||
testBtn | testBtn = MyForm.AddNewButton(MyForm,'testBtn','Scan Barcode...');<br> | ||
testBtn.Align | testBtn.Align = alCenter;<br> | ||
testBtn.Height | testBtn.Height = 100;<br> | ||
testBtn.Width | testBtn.Width = 200;<br> | ||
</blockquote> | </blockquote> | ||
Now that we have finished all the stages, let's use our "AddNewEvent" feature. We will perform a transaction. So when the button is clicked go to the procedure and read the barcode. Then write the code in "edit".<br> | Now that we have finished all the stages, let's use our "AddNewEvent" feature. We will perform a transaction. So when the button is clicked go to the procedure and read the barcode. Then write the code in "edit".<br> | ||
| Line 51: | Line 51: | ||
'''Code:'''<br> | '''Code:'''<br> | ||
Var | Var | ||
MyForm : TclForm; | MyForm : TclForm; | ||
| Line 76: | Line 75: | ||
} | } | ||
'''Output:'''<br> | '''Output:'''<br> | ||
{{#ev:youtube| https://www.youtube.com/watch?v=_t8zPqbWDRk}} | {{#ev:youtube| https://www.youtube.com/watch?v=_t8zPqbWDRk}} | ||
Revision as of 10:31, 13 November 2024
We use AddNewEvent when we want an event to occur. This occurrence triggers the execution of a procedure called an event handler. In this way, the transaction takes place. Example, Like a button click prompt.
AddNewEvent(TControl, TBasisEvent, String)
TControl : In its first parameter we will write what will trigger it. For example, take action when a button is clicked.
TBasisEvent : The second parameter is an actuation state. In other words, when the user makes a move, for example, when he clicks the button, proceed with the action.
String : We need to determine what will show when clicked. It can show a sample message or go to a procedure.
NOTE: Please refer to the documentation page for other accessible properties of the AddNewEvent function.
Sample:
Let's understand better with an example. In the example, when the button is clicked, the code will be scanned and this read barcode code will be written on edit.
For this, TClButton, TclEdit and then to create a form.
Var
MyForm:TclForm;
testBtn : TClButton;
testEdit : TclEdit;
After creating the definitions, when the button is clicked, a procedure should go and read the barcode in this procedure and write the barcode code in the edit. For this we need to define the following code.
void BtnOnClick;
{
MyForm.CallBarcodeReader(testEdit);
}
Now that the definitions and procedure have been created, let's start coding. Let's define our form.
MyForm = TclForm.Create(Self);
Then, let's make the settings of the variable we defined as "testEdit" to show the barcode code on the screen after the barcode is read. So let's create it by saying "AddNewEdit" and then determine its position and height. Let's assign its position to the top of our screen by saying "alTop".
testEdit = MyForm.AddNewEdit(MyForm,'testEdit','Barcode here ...');
testEdit.Align = alTop;
testEdit.Height = 40;
Let's define our button and create its design. In order for it to be in the middle of our screen, we need to define it as "alCenter".
testBtn = MyForm.AddNewButton(MyForm,'testBtn','Scan Barcode...');
testBtn.Align = alCenter;
testBtn.Height = 100;
testBtn.Width = 200;
Now that we have finished all the stages, let's use our "AddNewEvent" feature. We will perform a transaction. So when the button is clicked go to the procedure and read the barcode. Then write the code in "edit".
When "testBtn" is clicked, it will go to the "BtnOnClick" procedure.
MyForm.AddNewEvent(testBtn,tbeOnClick,'BtnOnClick');
Finally, we need to run our form. If this code is not written, the application screen will not appear.
MyForm.Run;
Code:
Var
MyForm : TclForm;
testBtn : TClButton;
testEdit : TclEdit;
void BtnOnClick;
{
MyForm.CallBarcodeReader(testEdit);
}
{
MyForm = TclForm.Create(Self);
testEdit = MyForm.AddNewEdit(MyForm,'testEdit','Barcode here ...');
testEdit.Align = alTop;
testEdit.Height = 40;
testBtn = MyForm.AddNewButton(MyForm,'testBtn','Scan Barcode...');
testBtn.Align = alCenter;
testBtn.Height = 100;
testBtn.Width = 200;
MyForm.AddNewEvent(testBtn,tbeOnClick,'BtnOnClick');
MyForm.Run;
}
Output: