Page 1 of 1

ExecuteJavaScript requires focus

Posted: Sun Dec 22, 2024 10:21 am
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!

Re: ExecuteJavaScript requires focus

Posted: Mon Dec 23, 2024 6:48 am
by dilfich
Have you tried it? Chromium.SetFocus(True);

Re: ExecuteJavaScript requires focus

Posted: Mon Dec 23, 2024 7:47 am
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.

Re: ExecuteJavaScript requires focus

Posted: Mon Dec 23, 2024 4:41 pm
by gui
Hi,

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

Thanks!