Dave Nottage 557 Posted October 5 3 hours ago, Dave Nottage said: It appears Android's WebView does not like part of the JavaScript (it works on macOS and iOS). I'm looking into it I discovered what the problem is: The "default" TWebBrowser implementation for Android uses loadUrl: procedure TAndroidWebBrowserService.EvaluateJavaScript(const AJavaScript: string); begin FWebView.loadUrl(StringToJString('javascript:' + AJavaScript)); UpdateContentFromControl; end; Which I guess does not accept the JavaScript that I provided. In TWebBrowserExt, it uses the evaluateJavascript method: procedure TPlatformWebBrowserExt.ExecuteJavaScript(const AJavaScript: string; const AHandler: TJavaScriptResultProc); begin if FWebView <> nil then FWebView.evaluateJavascript(StringToJString(AJavaScript), CreateValueCallback(AHandler)) else AHandler(cJavaScriptNullResult, -1); end; Which does work. I've now added a demo to the HowTo repository, which uses TWebBrowserExt, and it works on Android (as well as iOS and macOS) Share this post Link to post
MMSoft 0 Posted October 5 Sorry I can't get it to work, I already have a long list of folders in which Delphi contains the necessary files, and I have the idea that now all files can be found. But now I get this error message: [DCC Error] Unit1.pas(69): E2003 Undeclared identifier: 'cJavaScriptClickAtXY' It's possible that I'm using the wrong (outdated) file Share this post Link to post
Dave Nottage 557 Posted October 5 1 hour ago, MMSoft said: I have the idea that now all files can be found. But now I get this error message: [DCC Error] Unit1.pas(69): E2003 Undeclared identifier: 'cJavaScriptClickAtXY' The demo shows all the required folders in the Search path of Project Options. For that identifier you'd be missing the Features\JavaScript folder of Kastri Share this post Link to post
MMSoft 0 Posted October 6 Just downloaded the latest version: https://github.com/DelphiWorlds/Kastri And set up these search paths: C:\Users\mvsan\Downloads\Kastri-master\Kastri-master\Core C:\Users\mvsan\Downloads\Kastri-master\Kastri-master\API C:\Users\mvsan\Downloads\Kastri-master\Kastri-master\Controls C:\Users\mvsan\Downloads\Kastri-master\Kastri-master\Features\JavaScript C:\Users\mvsan\Downloads\Kastri-master\Kastri-master\Features\WebBrowserExt But keep getting this error message: [DCC Error] Unit1.pas(69): E2003 Undeclared identifier: 'cJavaScriptClickAtXY' [DCC Error] Unit1.pas(69): E2250 There is no overloaded version of 'Format' that can be called with these arguments Share this post Link to post
Dave Nottage 557 Posted October 7 (edited) 13 hours ago, MMSoft said: [DCC Error] Unit1.pas(69): E2003 Undeclared identifier: 'cJavaScriptClickAtXY' It's definitely in the repo. https://github.com/DelphiWorlds/Kastri/blob/58569bee28f5ce3caf5ceef588a46d13c161ce62/Features/JavaScript/DW.JavaScript.pas#L20 Did you add DW.JavaScript to the uses clause, as per the demo? Edited October 7 by Dave Nottage Share this post Link to post
MMSoft 0 Posted October 7 (edited) Of course, I use the demo, but my files are in a different place, so your search paths don't work for me. I'm getting this message now: Could not find a part of the path 'C:\Users\mvsan\Documents\Embarcadero\Studio\Projects\TEST\Lib\dw-kastri-base-3.0.0.jar'. Edited October 7 by MMSoft Share this post Link to post
Dave Nottage 557 Posted October 7 2 minutes ago, MMSoft said: Could not find a part of the path 'C:\Users\mvsan\Documents\Embarcadero\Studio\Projects\TEST\Lib\dw-kastri-base-3.0.0.jar'. The jar is not added to the search paths, it's added to the Libraries node of the Android 32-bit target, as per the demo readme. This is an image (which has been shortened, for brevity) of it: 4 minutes ago, MMSoft said: I've added these Search Paths for this: You don't add those paths. See above. Share this post Link to post
MMSoft 0 Posted October 7 (edited) Thanks, it works. I'm now going to try to incorporate it into my own Project. Edit: Is it possible to make a keyboard appear when the magnifying glass is clicked (Search on the site) so that search text can be typed ? Edit2: It now also works in my own App (and it runs on an Android TV). I do come across points for improvement, such as showing a keyboard when there is an input field. But also if the site does not fit on the Web browser to be able to scroll it. Also, if the site has shifted on the WebBrowser, clicking on it will no longer work because this shift will probably have to be taken into account. Edited October 7 by MMSoft Share this post Link to post
MMSoft 0 Posted October 10 (edited) I've been trying for days to get a little further, but unfortunately I can't get any further. For example, I try to ask how many pixels a site is shifted on the WebBrowser. How could I do that? Edit: Because I can't find how to do this, I'm trying to get it done through AI. It comes with the code below, but there I get the error messages: E2034 Too many actual parameters By the rules: procedure(const AResult: string) const JavaScriptHorizontal = 'window.scrollX'; JavaScriptVertical = 'window.scrollY'; procedure TForm1.WebBrowser1DidFinishLoad(ASender: TObject); begin // JavaScript om de huidige horizontale schuifpositie op te halen WebBrowser1.EvaluateJavaScript(JavaScriptHorizontal, procedure(const AResult: string) begin ShowMessage('Horizontaal verschoven: ' + AResult); end ); // JavaScript om de huidige verticale schuifpositie op te halen WebBrowser1.EvaluateJavaScript(JavaScriptVertical, procedure(const AResult: string) begin ShowMessage('Verticaal verschoven: ' + AResult); end ); end; Edited October 11 by MMSoft Share this post Link to post
MMSoft 0 Posted October 16 (edited) I now have a cursor and when I click on a button it executes it (if the page is not moved on the TWebBrowser). Thank you for that! Now my goal is to be able to view a website and use it on an android TV. I had hoped that if I could display a cursor and click on an item I could use a website, but that turns out to be a lot more difficult for me. The 1st problem I run into is that sometimes a site is too big, and it needs to be able to scroll. I have no idea how to make that happen. The 2nd problem is if the site is shifted on the TWebBrowser, clicking on a button on the site no longer works. And the 3rd problem I run into is, how can I enter something on an input field on the site ? Unfortunately, I can't figure this out, and help is very welcome Edited October 16 by MMSoft Share this post Link to post