Page 1 of 1

Native widgets don't receive keyboard input

PostPosted: Fri Oct 07, 2016 6:57 pm
by chellio
Problem is that my native widgets don't receive keyboard input because it is intercepted all time by CefBrowser. In other words CefBrowser never loss focus. I think problem is caused by poor integration of message loops. I use wxwidgets on Ubuntu and call CefDoMessageLoopWork on timer. One time when keyboard input is passed back to my native widgets is when I switch to antother window and then back to my application window. Can you give my any tips how to solve that problem?
Regards.

Re: Native widgets don't receive keyboard input

PostPosted: Sat Oct 08, 2016 1:12 am
by Czarek
I have similar problems in cefpython in the tkinter example that I've recently created. After I use keyboard in CEF browser I can't switch back to other Tk controls. Also when I move window without even using keyboard in CEF browser, the same thing happens, keyboard focus can no more be given to Tk controls. I've tried calling SetFocus(False) and SendFocusEvent, but CEF never loses focus. I've also implemented CefFocusHandler and tried many things, but couldn't make it work.

In cefclient switching focus between browser <> navigation bar works fine, but there is an issue with cursor when switching to url entry, there should be a blinking cursor for typing visibile, but it's not appearing.

I'm also calling CefDoMessageLoopWork in a timer. I've implemented external message pump, but it's buggy on Linux, I've reported Issue #2002.

Using Ubuntu 14.04 and CEF branch 2785.

Updated.

Re: Native widgets don't receive keyboard input

PostPosted: Mon Oct 10, 2016 4:14 pm
by chellio
I found solution.
To restore keyboard input to my native widgets I call gtk_window_present(1) with my top level window as parameter in respond to left-mouse click event. (little tricky).
To remove caret from native widgets when CefBrowser is focused I call wxwidgets specific SetFocus as a method of inner panel where CefBrowser is embedded. ( From CefFocusHandler::OnGotFocus ).

Re: Native widgets don't receive keyboard input

PostPosted: Mon Oct 10, 2016 11:50 pm
by Czarek
I followed your solution and also got it working, however there is still one issue. When my mouse is over url widget everything works fine, but when I hover mouse over CEF browser then keyboard focus on native url widget is lost, nothing reacts to my typing, neither the native widget, nor CEF browser, also none of the CefFocusHandler methods are being called at such time. When I hover the mouse back to url widget keyboard focus is restored. Calling CEF browser.SetFocus(False) doesn't help.

Re: Native widgets don't receive keyboard input

PostPosted: Fri Oct 28, 2016 4:40 am
by Czarek
Reported this along with a few other keyboard focus issues in the tracker: https://bitbucket.org/chromiumembedded/ ... -issues-on