Strange focus behavior

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.

Strange focus behavior

Postby Cromon » Sun Dec 15, 2013 9:14 am

Hello all!

In my application ive found a weird behavior with focus handling. If i create a browser and load up my site with just an input element in it i can click it and write into it using my keyboard, tho its shown as not-focused and no text-cursor is drawn. If i switch out of the window to another window and back in everything is fine, cursor shows and the input has the expected highlight. I set focus to my browser in OnAfterCreated and i even tested sendind a chain of messages like when i move to another window (WM_KILLFOCUS, and SendCaptureLost) to the browser but still i have to switch to another window first before there is real focus handling in the browser.

The browser is an off screen browser. I can provide code where neccessary but as there is already quite a lot its probably easier to just print the lines where the problem could be instead of all now.

Thanks in advance
Cromon
Cromon
Techie
 
Posts: 20
Joined: Sun Dec 15, 2013 9:04 am

Re: Strange focus behavior

Postby magreenblatt » Sun Dec 15, 2013 2:38 pm

Are you calling CefBrowserHost::SetFocus()?
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Strange focus behavior

Postby Cromon » Sun Dec 15, 2013 4:04 pm

Yes, right now i have this code:
Code: Select all
      void CefAppClient::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
         mBrowser = browser;
         sUIMgr->setActiveBrowser(browser);
         mBrowser->GetHost()->SetFocus(true);
         mBrowser->GetHost()->SendFocusEvent(true);
      }


I tried only one of them without any change, also setting the focus to false first and then to true, sending capture lost first then focus lost, then focus set, focus lost first, capture lost second, focus got third and basically every other combination also using messages (with SendMessage), nothing changes it. The input focus goes to the input element and you can enter text, but its not drawn highlighted and no caret is drawn unless you switch to another window and then back once.
Cromon
Techie
 
Posts: 20
Joined: Sun Dec 15, 2013 9:04 am

Re: Strange focus behavior

Postby magreenblatt » Sun Dec 15, 2013 4:21 pm

Cromon wrote:The input focus goes to the input element and you can enter text, but its not drawn highlighted and no caret is drawn unless you switch to another window and then back once.

How does it behave in the cefclient off-screen rendering example?
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Strange focus behavior

Postby Cromon » Sun Dec 15, 2013 4:35 pm

If i run the sample with off screen eanbled it works, but i cant find the difference. What else if not the SetFocus could cause the problem?
Cromon
Techie
 
Posts: 20
Joined: Sun Dec 15, 2013 9:04 am

Re: Strange focus behavior

Postby magreenblatt » Sun Dec 15, 2013 5:20 pm

Off-screen rendering has no focus or activation of its own. It must all come from your application. Look closely at how cefclient handles focus/activation in comparison to your own window model.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Strange focus behavior

Postby wcoder » Tue Jan 07, 2014 9:36 am

Do you solve your problem, i have exactly the same...

WCoder
wcoder
Newbie
 
Posts: 4
Joined: Tue Jan 07, 2014 9:17 am

Re: Strange focus behavior

Postby vaibhav » Thu Sep 21, 2017 2:21 am

Hello,
I have also same issue. We have an WPF application and in that we are using cefSharp browser(version 57). When we click on text field in browser we can type any with keyboard but text field shown not focused, no text cursor is drown.

If there is any solution for that please let me know.
vaibhav
Newbie
 
Posts: 4
Joined: Thu Jul 13, 2017 8:51 am

Re: Strange focus behavior

Postby douglas444 » Sat May 30, 2020 9:33 am

Same problem here. Im using Pandomium. If someone of you guys have found a solution, please, let me know.
douglas444
Newbie
 
Posts: 1
Joined: Sat May 30, 2020 9:25 am


Return to Support Forum

Who is online

Users browsing this forum: ndesktop and 36 guests