Custom Control - Getting data back to server

How do the built in widgets get data back to the server? When looking at the logs, I don’t see a lot of traffic back and forth and when I call something like “MyTextField.Text” it’s always up to date.

I am wrapping an editor right now and I can surely get text back to the server by calling Xojo.triggerServerEvent but I either have to do that on every character change or risk the server running a save process or something on stale data, no?

If you try to send with every key, it’ll be slow as molasses.

I’d suggest using SetTimeout to hold off triggering the event until the user has finished typing. Basically for every keystroke you do something like this:

if(myTimer) { ClearTimeout(myTimer); } //Clear the previous timer if there is one myTimer = SetTimeout(sendDataToServer,500); //Wait a half second

and then in your sendDataToServer function, you’d send the text value to the server.

Yes, I knew every key would be a disaster, what I’m not sure of is will the above method be the best way? How do the built in controls get data to the server so when the server calls MyTextField.Text it’s fresh?

We do what I suggested. We cache them until the text has stopped changing.

OK, thanks Greg. I’ll implement the same way then.