Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

Getting name of element when mouse is clicked

Post Reply
softtouch
Posts: 8
Joined: Tue Jan 14, 2020 8:28 am

Getting name of element when mouse is clicked

Post by softtouch »

How can I get the name of the element when I click on a webpage with the mouse, without using DOM?
I guess I could somehow use javascript, but how and if, how can I get the value back to Delphi to process the value?
User avatar
salvadordf
Posts: 4572
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Getting name of element when mouse is clicked

Post by salvadordf »

Hi,

There are several ways to do that.
  • Use the GlobalCEFApp.OnFocusedNodeChanged event and read the node.name value. This event is executed in the render process and you will need to send a process message with the node name value to the browser process.
  • Use JavaScript to get the node under the coordinates of the last mouse click and use a JavaScript extension to send the node name to the browser process.
Almost all the code you need is already in the JSExtension or JSRTTIExtension demos. Read the code comments in the JSExtension demo for a detailed explanation.
Post Reply