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.

ExecuteJavaScript requires focus

Post Reply
gui
Posts: 4
Joined: Thu Dec 19, 2024 12:27 am

ExecuteJavaScript requires focus

Post by gui »

Hi,

I tried to have some TButtons execute JavaScript with crm.ExecuteJavaScript(...).
However, since a recent update, it seems that CEFWindowParent1 must have the focus for ExecuteJavaScript to work.
If I click on the CEF control and then a TButton, ExecuteJavaScript works as expected.
If I directly click on a TButton when the form is loaded for instance, ExecuteJavaScript fails. Same if TButton keeps the focus after having been clicked.
Is there a workaround ?

Thanks!
dilfich
Posts: 368
Joined: Thu Nov 30, 2017 1:17 am

Re: ExecuteJavaScript requires focus

Post by dilfich »

Have you tried it? Chromium.SetFocus(True);
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: ExecuteJavaScript requires focus

Post by salvadordf »

Hi,

Try using a TSpeedButton, waiting until the page is fully loaded and setting the focus to the browser before executing the JavaScript code.
gui
Posts: 4
Joined: Thu Dec 19, 2024 12:27 am

Re: ExecuteJavaScript requires focus

Post by gui »

Hi,

Yes, I'm setting the focus before calling JavaScript. But'll I try TSpeedButton instead of TButton.

Thanks!
Post Reply