window.focus not working

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

window.focus not working

Postby kavadog » Wed Dec 16, 2015 12:10 pm

I'm using Cefclient 2526 64bit on Windows 8. From my javascript, I'm doing var w = window.open() to create a second browser window. This works fine and at this moment the new window has focus. I then click on the first/original window. I then use w.focus() to change the focus back to the second window. This fails.

Same test works correctly on Chrome browser.

What am I doing wrong?
kavadog
Techie
 
Posts: 28
Joined: Mon Jul 27, 2015 5:46 pm

Re: window.focus not working

Postby magreenblatt » Thu Dec 17, 2015 12:33 pm

Are you implementing CefFocusHandler for the popup window? Are any of the methods called when you execute w.focus()?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: window.focus not working

Postby kavadog » Thu Dec 17, 2015 1:39 pm

Yes, I implemented CefFocusHandler. GetFocus/SetFocus don't get called on w.focus. They do get called when I click on the Window title bar.
kavadog
Techie
 
Posts: 28
Joined: Mon Jul 27, 2015 5:46 pm

Re: window.focus not working

Postby magreenblatt » Thu Dec 17, 2015 1:55 pm

OK, please add a bug in the CEF issue tracker.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: window.focus not working

Postby kavadog » Thu Dec 17, 2015 3:03 pm

OK, I will open an issue.

As a workaround, I'm going to add a CefRequestHandler and expose a setfocus(window) method that can be called from javascript that will call the CefBrowserHost->SetFocus.

However, I don't know how to lookup the correct browser/frame context from a JS window object passed into CefRequestHandler via my setfocus(window) extension. Any thoughts on that one?
kavadog
Techie
 
Posts: 28
Joined: Mon Jul 27, 2015 5:46 pm

Re: window.focus not working

Postby magreenblatt » Thu Dec 17, 2015 3:29 pm

You can use CefBrowser::GetIdentifier() to retrieve the unique identifier for the CefBrowser. You can then pass that value to the browser process and have a lookup there to match the CefBrowsers that you've created, maintaining the CefBrowser list using calls to OnAfterCreated and OnBeforeClose.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: window.focus not working

Postby bharkanna » Thu Apr 30, 2020 9:21 am

@magreenblatt
Could you please let us know if there's any successful change/workaround to solve this issue.
bharkanna
Newbie
 
Posts: 2
Joined: Thu Apr 30, 2020 7:11 am

Re: window.focus not working

Postby bharkanna » Thu Apr 30, 2020 9:28 am

kavadog wrote:OK, I will open an issue.

As a workaround, I'm going to add a CefRequestHandler and expose a setfocus(window) method that can be called from javascript that will call the CefBrowserHost->SetFocus.

However, I don't know how to lookup the correct browser/frame context from a JS window object passed into CefRequestHandler via my setfocus(window) extension. Any thoughts on that one?


Were you able to get it work ?
bharkanna
Newbie
 
Posts: 2
Joined: Thu Apr 30, 2020 7:11 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 59 guests