text focus, alert, CefJSDialogHandler (request for mag)

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.

text focus, alert, CefJSDialogHandler (request for mag)

Postby michaeladamkatz » Mon Jun 10, 2019 10:24 pm

This is a request for magreenblatt to review the post viewtopic.php?f=6&t=16821&p=42080#p42080

The question boiled down to whether this text-input-focus-after-alert fix (https://bitbucket.org/chromiumembedded/ ... cef-builds) might have left a remaining problem for code like mine below that derives from CefJSDialogHandler to show a custom MessageBox instead of the default alert behavior of libcef.dll.

I still get the problem of not being able to click to focus any text input (until switching to another application and then back to cefclient) when I use my CefJSDialogHandler below. The question is whether there is something I can do differently in this code to make things work, or whether an additional fix in libcef.dll is needed to allow it to work.

Code: Select all
class NoaaJSDialogHandler : public CefJSDialogHandler
{
public:
  explicit NoaaJSDialogHandler();
  virtual bool 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) OVERRIDE;
  virtual bool OnBeforeUnloadDialog(CefRefPtr<CefBrowser> browser,
                                    const CefString& message_text,
                                    bool is_reload,
                                    CefRefPtr<CefJSDialogCallback> callback) OVERRIDE;
   
  void OnDialogClosed(CefRefPtr<CefBrowser> browser) OVERRIDE;
 
private:
  IMPLEMENT_REFCOUNTING(NoaaJSDialogHandler);
  DISALLOW_COPY_AND_ASSIGN(NoaaJSDialogHandler);
};

  myJSdialogHandler = new NoaaJSDialogHandler();

  CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() OVERRIDE {
    return myJSdialogHandler;
  }

bool NoaaJSDialogHandler::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 App", MB_OK );
         callback->Continue( true, "" );
         
         return true;
      }
   }
   
   return false;
}

bool NoaaJSDialogHandler::OnBeforeUnloadDialog(CefRefPtr<CefBrowser> browser,
                                                  const CefString& message_text,
                                                  bool is_reload,
                                                  CefRefPtr<CefJSDialogCallback> callback)
{
   callback->Continue( true, "" );
   
   return true;
}

void NoaaJSDialogHandler::OnDialogClosed(CefRefPtr<CefBrowser> browser)
{
}
michaeladamkatz
Techie
 
Posts: 49
Joined: Wed Jan 09, 2013 5:10 pm

Return to Support Forum

Who is online

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