VojkoCendak Posted December 4, 2023 Share Posted December 4, 2023 Hi, Websockets example full. The stringgrid is updated from websocket message event (ClientEvents...). But if I want to read cell values from code values from cell[] are empty. How can we get to the data in grid ? The same problem is with any control that's updated from JavaScript. thank you, Vojko Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 5, 2023 Share Posted December 5, 2023 Hello, C:\Program Files (x86)\FMSoft\Framework\uniGUI\Demos\Desktop\WebSocket - Grid Quote Link to comment Share on other sites More sharing options...
Harry Rogers Posted January 10 Share Posted January 10 I too have this question. The example does not seem to answer it - I think. E.G. the Server module uses a websocket to update a client side unilabel caption, for example with a variable calculated in the server module ("filename"), like this ........ if PersistentNode then BroadcastMessage('update', [ 'value', filename ], [boClientOnly]); .................... In the client main we use the clientevents to grab that message and update the label caption function form.socketmessage(sender, msg, params, eOpts) { if (msg == 'update') { MainForm.UniLabel1.setText(params.value); } } Visually the label does indeed update the caption to show the current value of "filename". HOWEVER on the client side showmessage(unilabel1.caption); Shows the pre-existing caption NOT the updated text sent from the websocket. What's the mechanism to update the internal representation of label.caption to match what's actually displayed? Quote Link to comment Share on other sites More sharing options...
Harry Rogers Posted January 10 Share Posted January 10 UPDATE: Resolution - [well good enough anyway] - I'm sure it creates plenty of back and forth traffic - if anyone knows a better way then please dive in! If the Websocket is used to update the text value of a UniEdit rather than a unilabel.caption then the Onchange event of that edit is fired and the uniedit.text value is the new value sent by the websocket. (N.B you need to use setValue from js to write the text field of a uniedit. ) ( I tried with a dynamically created on change event for the label (as per the demo example dyn.dproj) but that never fired from the websocket update - only manual changes) So on the Client side we how have this js event function form.socketmessage(sender, msg, params, eOpts) { if (msg == 'update') { // MainForm.UniLabel1.setText(params.value); << never updates the underlying value only the rendered one. MainForm.UniEdit1.setValue(params.value); // Works fine } } Then use the standard Delphi/Unigui Onchange event of the UniEdit to get at the new value. 1 Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted January 11 Share Posted January 11 14 hours ago, Harry Rogers said: MainForm.UniEdit1.setValue(params.value); // Works fine Thank you Harry This is what should post every unigui developer. Your expertise is precious Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.