You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.
the point is CefRenderProcessHandler := TCustomRenderProcessHandler.Create;
this line will tell CEF to execute the TCustomRenderProcessHandler.OnWebKitInitialized function, in this function:
procedure TCustomRenderProcessHandler.OnWebKitInitialized;
begin
{$IFDEF DELPHI14_UP}
TCefRTTIExtension.Register('app', TTestExtension);
{$ENDIF}
end;
will register a js extension, named app, with the implementation by TTestExtension
TTestExtension = class
class function hello: string;
class procedure mouseover(const data: string);
end;
{ TTestExtension }
class procedure TTestExtension.mouseover(const data: string);
var
msg: ICefProcessMessage;
begin
msg := TCefProcessMessageRef.New('mouseover');
msg.ArgumentList.SetString(0, data);
TCefv8ContextRef.Current.Browser.SendProcessMessage(PID_BROWSER, msg);
end;
class function TTestExtension.hello: string;
begin
Result := 'Hello from Delphi';
end;
so, you can all app.hello in the js code which will return 'Hello from Delphi'.
But please notice that, all the code executes in the render process, not in the main process, so, in the implementation code, do not directly call TForm or the main process's functions, or will led to exception, you need to send message by call SendProcessMessage of the browser demonstrated by the code above with mouseover function.
Thanks for all the authors of this project, like @hgourvest , @boomsya who make this great project,
it is more stable than CEF4delphi, thank you.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
hi. Can i ask for your help?
i need register method MyMethod in any one demo project and call method in JS: window.external.MyMethod();
can you show me how can i do this in this component?
The text was updated successfully, but these errors were encountered: