paul.coshott Posted July 2, 2019 Share Posted July 2, 2019 Hi All, I've just learned how to change the background color of a panel using client side JS in the ClientEvents property . Works great (thanks Sherzod). But I also have another case where I am changing the background color of a panel (and one where I change the background color of a label), but the color it changes to depends on quite a few factors and also whether it was previously selected or not selected. So what I'm asking, is can I call JS code from within my pascal coded events. And if I can, how do I do this? An example of changing the background color of an object would be great. Thanks, Paul Delphi 10.2 Pro, uniGUI 1.9.0.1502 Complete Professional, Windows 10 Pro Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 2, 2019 Share Posted July 2, 2019 1 hour ago, paul.coshott said: So what I'm asking, is can I call JS code from within my pascal coded events. And if I can, how do I do this? An example of changing the background color of an object would be great. Hi, Well, if you use a code on the server side, it is better to use pascal code. Or you can use the object's JSInterface property. JSInterface.JSCall() JSInterface.JSCallDefer() ... Quote Link to comment Share on other sites More sharing options...
paul.coshott Posted July 2, 2019 Author Share Posted July 2, 2019 Hi Sherzod, Thanks for the info. Could you give me an example of using the JSInterface to change the background color of a panel? Thanks, Paul Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 2, 2019 Share Posted July 2, 2019 2 hours ago, paul.coshott said: Thanks for the info. Could you give me an example of using the JSInterface to change the background color of a panel? UniPanel1.Color := clGreen; UniPanel1.JSInterface.JSCall('setBodyProp', ['background-color','green']); UniPanel1.JSInterface.JSCall('setBodyProp', ['background-color','#008000']); UniPanel1.JSInterface.JSCall('setBodyProp', ['background-color', uniColor2Web(clGreen)]); //uses ... uniGUIJSUtils; Quote Link to comment Share on other sites More sharing options...
paul.coshott Posted July 3, 2019 Author Share Posted July 3, 2019 Hi Sherzod, Thanks for the example. It worked fine, but it was no faster than the pascal code. So, next question. Is it possible to fire a java script event from within the pascal code, that will cause the background color to change quicker? Cheers, Paul 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.