1

I am using Delphi XE2 and Chromium CEF4Delphi. I am trying to use a web page via the TChromiumWindow component and would like to detect when an element is selected / clicked.

I saw this post..

Delphi Chromium - launch a command in Delphi application when button in web page is clicked by user

Unfortunately, I cant find the function AddEventListenerProc in the CEF4Delphi library. Neither can I find an alternative way to monitor a button / element click.

I would like to use the TChromiumWindow component to act as a "fron-end" to my app and would like to monitor user button clicks etc.

Can anyone help please ? I did try the developer forum but I dont see much activity there and was unable to register.

Many thanks..

DaveLister
  • 127
  • 1
  • 9

1 Answers1

1

The DCEF3 project has a group here : https://groups.google.com/forum/#!forum/delphichromiumembedded

But the CEF4Delphi and OldCEF4Delphi projects have a developers forum here : https://www.briskbard.com/forum/

That forum has new posts almost every day and I try to answer them as soon as I can, usually in less than 24 hours.

If you have problems creating an account just send me a message and I'll activate your account manually.

The link you posted is very old and many things have changed in CEF since 2012.

There are several ways to detect when a HTML element has been selected, clicked, etc.

  • You can use a JavaScript event like "onclick" that calls a custom JavaScript extension. That extension would send a process message to the browser process to notify that the user clicked that element.
  • You can also use the GlobalCEFApp.OnFocusedNodeChanged that is triggered when an HTML element has been focused. This event is executed in the "render" process so you will also need to send a process message to the main browser process that the focused element has changed.

Use the JSRTTIExtension or the JSExtension demos as a template for your app.

They show you how to set a "mouseover" event that calls the "myextension.mouseover" function defined in a custom JS extension. The myextension.mouseover function executes Delphi code and sends a process message to the main browser process with some HTML information that is shown in the status bar.

They also have an example for a "MutationObserver" that calls a generic "myextension.sendresulttobrowser" function in the JS extension that sends the "value" attribute to the browser process.

Build the demo and right-click on the web page when it's fully loaded. Then select the "Set mouseover event" or "Add mutation observer" options to test what I described.

  • Thanks a lot Salvador, I will explore those ideas. I will re-try registering with the forum (last time I just did not recieve and email,) Cheers.. – DaveLister Jul 10 '19 at 09:04