text focus, alert, CefJSDialogHandler (request for mag)
Posted: 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.
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)
{
}