Page 1 of 1

[How To] Cursor coordinates in the event

PostPosted: 15 Dec 2014 11:58
by Alexander Bulei
To obtain the cursor coordinates, and send to the event, you need to use the BrowserParams.
Below, you will find the very simple example with IWCGJQButton.

Note

When you define the code of BrowserScript of BrowserParams, you must have attention on the event arguments.

E.g: IWCGJQButton.OnClick passes the event object as "e" parameter.



Example:

* Create and define the BrowserParams :

delphi code
procedure TIWForm1.IWAppFormCreate(Sender: TObject);
begin
with IWCGShowCursorPosBtn.JQButtonOptions.OnClick.BrowserParams.Add do
begin
ServerName:= 'curX';
BrowserScript:= 'e.pageX';
end;
with IWCGShowCursorPosBtn.JQButtonOptions.OnClick.BrowserParams.Add do
begin
ServerName:= 'curY';
BrowserScript:= 'e.pageY';
end;
end;


* Using of BrowserParams in Event:

delphi code
procedure TIWForm1.IWCGShowCursorPosBtnJQButtonOptionsClick(Sender: TObject; AParams: TStringList);
var
PosX, PosY: Integer;
begin
PosX:= StrToIntDef(AParams.Values['curX'],-1);
PosY:= StrToIntDef(AParams.Values['curY'],-1);
WebApplication.ShowMessage('X: ' + IntToStr(PosX) + #13+#10 + 'Y: ' + IntToStr(PosY) );
end;