Jump to content

Replace Button.onClick by ExtEvents.click


irigsoft

Recommended Posts

Hello everyone,

Is it possible to somehow perform my function through ExtEvents

I create MyFunctionOnButtonClick (Sender: TObject) and replace TButton.onClick with it.

How can I use this MyFunctionOnButtonClick and replace TBUtton.ClientEvents.ExtEvents.click

My problem is:

1. I have my own OnClick control function for all buttons, and replace it with Form creation.

2. This function performs some actions on the server.

3. It's slow and I want to speed up and run the ClientSide function.

4. I guess this is possible by replacing ExtEvents.click with my feature, right?

 

I found some example, but dont know how to apply it:

or 

here I use it in a moment:

------------------ Form.Create

      IF Component.ClassType = TuniButton then
          TuniButton (Component).OnClick := MyFunctionOnButtonClick ;

------------  MyFunctionOnButtonClick

procedure MyFunctionOnButtonClick (Sender :TObject);

begin

ShowMessage ('ButtonClicked');

IsButtonClicked := True;

end;

 

I want to replace with:

      IF Component.ClassType = TuniButton then
          TuniButton (Component).ClientEvents.ExtEvents.Click := MyFunctionOnButtonClick ;

Link to comment
Share on other sites

5 minutes ago, Sherzod said:

Hello,

You need write JavaScript code.

Thanks,

My code use some VCL components, external DLL s and  data from visual components to execute different functions on dll's,

like example :

GETFUNC - start function on POSFunction.dll (where are my functions plased)

OnBtnClick - > GETFUNC (SetPropValue,MyLabel.Caption, GetPropValue|myButton1|Caption);

OnBtnClick - > GETFUNC (GetFieldValue,MyDBGridMenu,EndPrice,nil);

OnBtnClick - > GETFUNC (CALCULATE,Result_1 * 1.20, 4);

OnBtnClick - > GETFUNC (SetPropValue,MyLabelResult.Caption, Result_3);

 

and so on.

 

 

Link to comment
Share on other sites

Just now, irigsoft said:

My problem is when click on some button, no mather what function executes, showmask wait some 2-3 seconds .

Is it on the developer's machine? Or have you deployed to the server (If so, network speed, is there antivirus software installed)?..

Link to comment
Share on other sites

I try it on different servers, and different client devices, even on server machine : localhost

Wait Showmask is 2 seconds.

1. I think, some client - server execute proccesses have wait time, how to analize this

2. If I use javascript on extEvents.click it is possible to get from VCL values, like: get label2.caption on javascript code?

3. If I use MyButton.ExtEvents.click, it is possible to combine VCL.MyButton.OnClick and Extevents.click?

Link to comment
Share on other sites

14 minutes ago, irigsoft said:

2. If I use javascript on extEvents.click it is possible to get from VCL values, like: get label2.caption on javascript code?

Yes.

14 minutes ago, irigsoft said:

3. If I use MyButton.ExtEvents.click, it is possible to combine VCL.MyButton.OnClick and Extevents.click?

I don't fully understand what you mean when you say combine, but I guess in this case you will send a request to the server anyway.

Link to comment
Share on other sites

2 minutes ago, Sherzod said:

Yes.

I don't fully understand what you mean when you say combine, but I guess in this case you will send a request to the server anyway.

In the begining on my project i try to create button.onClick and on same button.clientevents.extevent.click  functions , but button.onclick not execute if ExtEvents.click exist.

Link to comment
Share on other sites

1 minute ago, irigsoft said:

In the begining on my project i try to create button.onClick and on same button.clientevents.extevent.click  functions , but button.onclick not execute if ExtEvents.click exist.

I couldn't reproduce this behavior. Can you make a simple testcase?

Link to comment
Share on other sites

2 minutes ago, Sherzod said:

Yes.

Okay, I'll explain a simple functionality and if you can give me advice on how to optimize it in combination javascript and vcl.

On btn.onclick I must get label1.caption from MyForm

get label2.Caption from MyForm.MyPanel2 and change value to MyForm.Label3 with results from label1 and label2

I use External dll, to set value Label3.caption, but if I must get values from label1 and label2 i use MyForm.FindComponent by name and after find it i get properties value

So:

1. When Click on button - how to get values from label1 and label2 by javascript

2. After get it I save result on uniMainmodule.variable - ResultVariable

3. Send ResultVariable value to external dll and wait to execution bring result from dll.

4. apply new value to label3.caption

 

Link to comment
Share on other sites

4 minutes ago, Sherzod said:

For example, for UniLabel1:


MainForm.UniLabel1.text;

 

If I use ExtEvent.click and want to set label3.caption to uniMainmodule. variable how to apply it?

like:

function click(sender, e, eOpts)
{
 uniMainmodule.MyVariable := MainForm.uniLabel1.caption

 uniMainmodule.MyVariable2 := MainForm.uniPanel1.uniGroupBox.uniLabel8.caption

}

after that on Button.OnClick

Send to external dll with function ChangedatawithDLL (Label4,Caption, uniMainModule.MyVariable + uniMainModule.MyVariable2)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...