Focus issues with Cef

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.

Focus issues with Cef

Postby arvelius » Mon Feb 15, 2016 5:27 am

hi, Cef (2526) seems to set the input focus to itself after creating or loading a page.
Thus, I have a very simple task which I'm not able to solve: in cefclient, let the input focus stay in the address textBox. And I do not want to solve it by any timer or put the focus back in the LoadEnd. I simply need the address field to be the one and only control receiving a focus, but webbrowser always steals it
arvelius
Techie
 
Posts: 46
Joined: Wed Sep 17, 2014 8:37 am

Re: Focus issues with Cef

Postby amaitland » Mon Feb 15, 2016 6:54 am

arvelius wrote:I simply need the address field to be the one and only control receiving a focus, but webbrowser always steals it


Steals it I think is slightly inaccurate, I think you'll find it's deliberately set. Try searching through the cefclient code for something like SetFocus(true);
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1292
Joined: Wed Jan 14, 2015 2:35 am

Re: Focus issues with Cef

Postby arvelius » Mon Feb 15, 2016 7:22 am

actually I came with this issue from the .net wrapper and in .net setting the focus is more straightforward (setting the TabIndex property to the controls in the order in which they should get focus when the 'tab' key is pressed and the control with lowest TabIndex is to be focused when the form is opened). This simply doesn't work now, although it worked in 3.2454
I'm afraid I'm not as experienced C++ to find where the problem really is, but I've tried to modify the cefclient to keep the focus in the address bar, but got into the same situation...
arvelius
Techie
 
Posts: 46
Joined: Wed Sep 17, 2014 8:37 am

Re: Focus issues with Cef

Postby amaitland » Mon Feb 15, 2016 7:39 am

There are at least three CEF .Net wrappers that I'm aware of, so best to be specific.
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1292
Joined: Wed Jan 14, 2015 2:35 am

Re: Focus issues with Cef

Postby arvelius » Mon Feb 15, 2016 7:49 am

amaitland wrote:There are at least three CEF .Net wrappers that I'm aware of, so best to be specific.

sorry, it's Xilium
arvelius
Techie
 
Posts: 46
Joined: Wed Sep 17, 2014 8:37 am

Re: Focus issues with Cef

Postby amaitland » Mon Feb 15, 2016 8:48 am

If you haven't already might be worth checking through the commit logs for both projects.

There is at least one Windows Focus related change in 2526
https://bitbucket.org/chromiumembedded/ ... 526?page=2
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1292
Joined: Wed Jan 14, 2015 2:35 am

Re: Focus issues with Cef

Postby arvelius » Sun Feb 21, 2016 7:38 am

Well, finally I figured it out.
I have rewritten the cefClient sample not to create the browser on startup, but I create it when a certain charater is pressed in the textBox. My goal is to keep the focus in the textBox even after the page is loaded.
One place the focus is set is in the CefBrowserHostImpl::LoadURL - this results in a call to the CefFocusHandler where I return 'true' to disallow setting the focus. So far so good, this is easily configurable and if the developer needs to set the focus when the page is loaded, this is the way how to achieve it.
The second place is CefWindowDelegateView::Init where params.activatable is set to ACTIVATABLE_YES. On Windows, this happens everytime. In Widget::Show() this results in calling native_widget_->Show() instead of native_widget_->ShowWithWindowState(ui::SHOW_STATE_INACTIVE) and thus the input focus is lost, without any way to control it. This is relevant to the https://bitbucket.org/chromiumembedded/ ... abf90d2691 issue which fixes a different bug, but I think it has the side-effect i described...
arvelius
Techie
 
Posts: 46
Joined: Wed Sep 17, 2014 8:37 am

Re: Focus issues with Cef

Postby akjana » Tue Mar 08, 2016 7:03 pm

The default ACTIVATABLE_YES settings in CefWindowDelegateView::Init is very concerning.
We happen to lazy load the CEF Window and it is causing race conditions with Focus now because of this.
In the near future, we are planning to have multiple CEF Windows in the same application and they would be lazy loaded in parallel maybe, we want to avoid such race conditions with Focus.

Would it be possible to pass a browser setting to control the initial Activation status ? This would really help us. Thanks
akjana
Techie
 
Posts: 39
Joined: Wed Feb 03, 2016 2:15 am

Re: Focus issues with Cef

Postby magreenblatt » Wed Mar 09, 2016 11:37 am

akjana wrote:The default ACTIVATABLE_YES settings in CefWindowDelegateView::Init is very concerning.
We happen to lazy load the CEF Window and it is causing race conditions with Focus now because of this.
In the near future, we are planning to have multiple CEF Windows in the same application and they would be lazy loaded in parallel maybe, we want to avoid such race conditions with Focus.

Would it be possible to pass a browser setting to control the initial Activation status ? This would really help us. Thanks

Please add a bug. Pull requests welcome.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Focus issues with Cef

Postby akjana » Thu Mar 17, 2016 6:57 pm

I'll file a bug. Thanks
akjana
Techie
 
Posts: 39
Joined: Wed Feb 03, 2016 2:15 am

Next

Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 41 guests