Jump to content

JS Syntax


Harry Rogers

Recommended Posts

HI

 

What's the syntax for calling a Delphi function or procedure from JS ?

When some condition is met in the Javascript I want to call a delphi procedure, from the Clientevents demos it's easy to see setting text and moving elements around the form but I can't see calling a delphi procedure.

 
Here is a simple delphi procedure
 
procedure TMainForm.btnMaskClick(Sender: TObject);
begin
 bMasked := true;
 frmmask.ShowModal();
end;
........
 
and some JS in the script property of the form
......
......
if (_MaxTry >= MAX_COUNT) {
      MainForm.lblWarning.setText('You have used all attempts');    << works fine
      MainForm.lblStatus.setPosition(x,y);                             << works fine
      MainForm.btnMaskClick(self);                      <<<< this is the one I don't know the syntax of
    }
 
 
Many thanks
 
Harry
Link to comment
Share on other sites

Hi

 

You can create ajax request.

 

For example in some component's click clientevents there is this code bellow

function click(sender, e, eOpts)
{
   var time = 0;
   for (i=0;i<=5000;i++)
   {
     time +=1;
     MainForm.UniButton1.setText(time);
   }
   if (time >= 5000)
   {
      ajaxRequest(MainForm.UniButton1, 'SomeRequestNamedByMe', []); 
    }
}

and in onAjaxEvent there is this code

procedure TMainForm.UniButton5AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName='SomeRequestNamedByMe' then
  begin
      myProcedure;
  end;
end;

First call ajaxRequest in JS when condition is true. Second one call procedure named myProcedure in delphi.

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...