paul.coshott Posted July 2, 2019 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
Sherzod Posted July 2, 2019 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() ...
paul.coshott Posted July 2, 2019 Author 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
Sherzod Posted July 2, 2019 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;
paul.coshott Posted July 3, 2019 Author 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
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now