cannot focus text input boxes after javascript alert()

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.

cannot focus text input boxes after javascript alert()

Postby michaeladamkatz » Sat Feb 16, 2019 9:40 pm

I am using CEF Version: 3.3578.1860.g36610bd on Windows 10.

I have a CEF application based on the cefclient example.

After calling alert( "anything" ) in javascript and clicking OK to dismiss the alert dialog box, I cannot focus on any <input type="text"...> element, either by clicking the element, or by using the tab key. I *am* able to drag to select text that is already in the element, and the text highlights in gray as if the control is disabled. (I can also copy this gray text once it's selected.) I am able to use other controls check as check boxes and <select> controls.

HOWEVER, when I switch to another application (either using the taskbar or alt-tab) and then back to the CEF application, the text inputs behave normally again.

At first I thought this might be due to me having an override js dialog box handler:

Code: Select all
  CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() OVERRIDE {
    return this->_myJSdialogHandler;
  }

bool MyJSDialogHandler::OnJSDialog(CefRefPtr<CefBrowser> browser,
                                        const CefString& origin_url,
                                        JSDialogType dialog_type,
                                        const CefString& message_text,
                                        const CefString& default_prompt_text,
                                        CefRefPtr<CefJSDialogCallback> callback,
                                        bool& suppress_message)
{
   switch ( dialog_type )
   {
      case JSDIALOGTYPE_ALERT:
      {
         MessageBox( browser->GetHost()->GetWindowHandle(), message_text.c_str(), L"My Application", MB_OK );
         callback->Continue( true, "" );
         
         return true;
      }
      
      case JSDIALOGTYPE_CONFIRM:
      {
         int r = MessageBox( browser->GetHost()->GetWindowHandle(), message_text.c_str(), L"My Appliction", MB_OKCANCEL );
         callback->Continue( ( r == IDOK ), "" );
         
         return true;
      }
   }
   
   return false;
}


However, even when I comment out my handler and use the default CEF alert box I get the same problem.
michaeladamkatz
Mentor
 
Posts: 50
Joined: Wed Jan 09, 2013 5:10 pm

Re: cannot focus text input boxes after javascript alert()

Postby amaitland » Sat Feb 16, 2019 11:53 pm

Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1292
Joined: Wed Jan 14, 2015 2:35 am

Re: cannot focus text input boxes after javascript alert()

Postby michaeladamkatz » Sun Feb 17, 2019 3:41 am

Thanks for the quick reply.
michaeladamkatz
Mentor
 
Posts: 50
Joined: Wed Jan 09, 2013 5:10 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 89 guests