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.

Problem after upgrade to CEF 88.1.6 (Windows64) with popup Windows -- cursor missing

Post Reply
Christoph
Posts: 25
Joined: Fri Feb 23, 2018 6:31 am

Problem after upgrade to CEF 88.1.6 (Windows64) with popup Windows -- cursor missing

Post by Christoph »

Hello,

we did an upgrade to CEF 88.1.6 (Windows64) and now we do have the problem that popup windows in the browser do not have a cursor.

The fields in the popup windows are displayed correctly, one can enter values, but it is not possible to see, which field is focused and a klick on a single field does not show the cursor in this field.

Any suggestion how to solve this problem?

Thank you in advance!
Christoph
Posts: 25
Joined: Fri Feb 23, 2018 6:31 am

Re: Problem after upgrade to CEF 88.1.6 (Windows64) with popup Windows -- cursor missing

Post by Christoph »

Reading of the article "How to set focus to / set caret into input field"

https://www.briskbard.com/forum/viewtopic.php?f=8&t=1116&p=4851&hilit=cursor#p4851

espcially the post by Lu53 » Mon Jan 20, 2020 4:32 pm

points to the OnSetFocus event.

I do have the following code:

Code: Select all

procedure TBrowserForm.crmSetFocus(Sender: TObject;
  const browser: ICefBrowser; source: TCefFocusSource; out Result: Boolean);
begin
  inherited;
  if source = TCefFocusSource.FOCUS_SOURCE_NAVIGATION then
    Result := True;

end;
Commenting out this part results in the fact, that the popup window is not shown in the foreground...
But: the fields in the popup window can get the cursor!
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Problem after upgrade to CEF 88.1.6 (Windows64) with popup Windows -- cursor missing

Post by salvadordf »

Sorry for the long delay.

I can't reproduce the focus and cursor issue in the PopupBrowser2 demo. Please, compare the code in your application with that demo to see if something else is causing this issue.

CEF has some known issues with focus as you can see here :
https://www.briskbard.com/forum/viewtopic.php?f=8&t=1467
https://www.briskbard.com/forum/viewtopic.php?f=10&t=1198

There is a workaround but it creates other issues as you can see in the BitBucket link.

The TChromium.OnSetFocus event has this code comments :
Called when the browser component is requesting focus. |source| indicates where the focus request is originating from. Return false to allow the focus to be set or true to cancel setting the focus.
https://magpcss.org/ceforum/apidocs3/projects/(default)/CefFocusHandler.html#OnSetFocus(CefRefPtr%3CCefBrowser%3E,FocusSource)

Please provide a step-by-step guide to reproduce this issue in my computer with a demo.
Christoph
Posts: 25
Joined: Fri Feb 23, 2018 6:31 am

Re: Problem after upgrade to CEF 88.1.6 (Windows64) with popup Windows -- cursor missing

Post by Christoph »

Thank you for the response, I looked at the PopupBrowser2 demo.

The difference is, that in the demo project a child form is opened to display the popup of the website display in the main form, controlled by the OnBeforePopup event of TChromium component in the main form.

In my case I do not have a child form and no OnBeforePopup event, but I use the OnSetFocus event as described earlier

Code: Select all

if source = TCefFocusSource.FOCUS_SOURCE_NAVIGATION then
    Result := True;
To reproduce the problem, please comment out the OnBeforePopup event of TChromium component in the main form, then add the OnSetFocus event as described above. Then you open a website where a click on a button opens a popup with some fields which can be edited. Here you will see, that the fields, e.g. a textedit, does not get the cursor.

In previous CEF versions this problem was not there..
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Problem after upgrade to CEF 88.1.6 (Windows64) with popup Windows -- cursor missing

Post by salvadordf »

Removing the TChromium.OnBeforePopup event allows CEF to create the child form automatically but in this case, the browser events from the new child form are also handled by the TChromium component in the main Delphi form.

This means that the TBrowserForm.crmSetFocus procedure will be triggered by the main browser and also by the browser in the child forms.

The MiniBrowser demo also allows CEF to create the child forms and the procedures handling TChromium events call TChromium.IsSameBrowser(browser) to know if the event was triggered by the TChromium component in the main form or a child form.
Christoph
Posts: 25
Joined: Fri Feb 23, 2018 6:31 am

Re: Problem after upgrade to CEF 88.1.6 (Windows64) with popup Windows -- cursor missing

Post by Christoph »

Thank you for your reply.

I started the MiniBrowser demo. Unfortunately the same problem occurs, so in my point of view it makes no difference whether TChromium events call TChromium.IsSameBrowser(browser) to know if the event was triggered by the TChromium component in the main form or a child form or not.

Maybe this screenshot demonstrates the problem a little bit better, you can not place the cursor e.g. in the field "Betreff"
CEF_Cursor.png
Any further idea?
You do not have the required permissions to view the files attached to this post.
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Problem after upgrade to CEF 88.1.6 (Windows64) with popup Windows -- cursor missing

Post by salvadordf »

Please, download CEF4Delphi from GitHub again.

I just uploaded a workaround for this issue. It's probably not a perfect solution but I could see a blinking cursor in the popup windows after a WinApi.Windows.SetFocus call :
https://github.com/salvadordf/CEF4Delphi/blob/12cce1cbbadc303cf904a6b0b228d3aeb02fd986/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas#L726
Christoph
Posts: 25
Joined: Fri Feb 23, 2018 6:31 am

Re: Problem after upgrade to CEF 88.1.6 (Windows64) with popup Windows -- cursor missing

Post by Christoph »

Thank you very much for the modified MiniBrowser demo.

The solution there also works on our side, so the users will be happy about that! :D :D :D
Post Reply