Page 1 of 1
FMX Javascript evaluation
Posted: Tue May 07, 2019 9:42 pm
by axa
Hi,
How can I evaluate javascript function with FMXChromium and return results.
The sample provided JSEval is available only for VCL applications...
FMX.TWebbrowser from embarcadero ha too many bugs and is unreliable.
I have posted the same question on GitHub, sorry for duplicate
Thank you in advance,
Pavel
Re: FMX Javascript evaluation
Posted: Wed May 08, 2019 8:46 am
by salvadordf
Hi,
You need to mix the SimpleFMXBrowser and JSEval demos into one but please, if you haven't read the following web pages take a few minutes to read them :
https://www.briskbard.com/index.php?lang=en&pageid=cef
https://bitbucket.org/chromiumembedded/ ... gration.md
Read the code comments in the SimpleFMXBrowser and JSEval demos too because adding a TChromium component to an FMX app requires a few steps and the JavaScript demos require inter-process messages and Windows messages.
Use the SimpleFMXBrowser demo as the template for your application and add what you need from the JSEval demo.
You will probably need all this :
- Use the TChromium.OnBeforeContextMenu and TChromium.OnContextMenuCommand events and copy their code from Chromium1BeforeContextMenu and Chromium1ContextMenuCommand.
- Copy RenderProcessHandler_OnProcessMessageReceivedEvent and assign it to GlobalCEFApp.OnProcessMessageReceived
- Copy ParseEvalJsAnswer
- Use the TChromium.OnProcessMessageReceived to receive the results. Copy Chromium1ProcessMessageReceived.
If your application needs to show or modify anything using the user interface then you will need to send a MINIBROWSER_EVALJSCODE message from TChromium.OnContextMenuCommand but if you already know what you need to evaluate then copy most of the code from EvalJSCodeMsg into TChromium.OnContextMenuCommand to send the EVAL_JS process message.
If you need to show the final results in the user interface then you will need to send a Windows message from the TChromium.OnProcessMessageReceived event. The JSEval demo uses MINIBROWSER_SHOWTEXTVIEWER to show the results in a child form.
As you can see, all the FMX demos use a modified IFMXApplicationService in the uFMXApplicationService.pas file.
Modify the TFMXApplicationService.HandleMessage to add your custom Windows messages.
Re: FMX Javascript evaluation
Posted: Wed May 08, 2019 9:30 am
by axa
Dear Salvador,
First of all I want to thank you for your fast reply.
I will try your suggested solution and I will let you know if any problem arise.
Thanks again,
Pavel