Custom Events
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
// Creates the remote object
FRo := TJSObject.Create('ro');
// Adds the event
FRo.Events.Add('mousePositionChanged')
.AddArgument('coords', JSDT_JSON); // Adds the mouse position as JSON
FRo.ApplyModel;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
begin
FRo.Events['mousePositionChanged']
.ArgumentAsJSON('coords', '{"x": ' + X + ', "y": ' + Y + '}')
.Fire;
end;// Creates the remote object
ro = new JSObject("ro");
// Adds the event
ro.Events.Add("mousePositionChanged")
.AddArgument("coords", IJSDataType.JSDT_JSON) // Adds the mouse position as JSON
ro.ApplyModel();
...
...
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
ro.Events["mousePositionChanged"]
.ArgumentAsJSON("coords",
"{ \"x\": " + MousePosition.X + ", \"y\": " + MousePosition.Y + "}")
.Fire();
}// Creates the remote object
ro = new JSObject("ro");
// Adds the eventro.Events.Add("mousePositionChanged")
.AddArgument("coords", IJSDataType.JSDT_JSON) //the mouse position as JSON
ro.ApplyModel();
...
...
private void Form1_MouseMove(object sender, MouseEventArgs e)
{ ro.Events["mousePositionChanged"]
.ArgumentAsJSON("coords", "{ \"x\": " + MousePosition.X + ", \"y\": " + MousePosition.Y + "}")
.Fire();
} jsro.on('ro', 'mousePositionChanged', function (coords) {
console.log('mouse moved to [' + coords.x + ', ' + coords.y + ']');
});