Skip to content
Snippets Groups Projects
Commit 88c0df7c authored by svornost's avatar svornost
Browse files

Apparently Chrome's ENTIRE javascript debugger is exposed in CEF, so we can just...use it. Cool.

parent 1be723b2
No related branches found
No related tags found
1 merge request!5145Add standalone host executable for FreeCities, with unlimited storage adapter
......@@ -151,6 +151,38 @@ void FCHostHandler::OnBeforeDownload(CefRefPtr<CefBrowser> browser,
callback->Continue(suggested_name, true);
}
bool FCHostHandler::OnPreKeyEvent(CefRefPtr<CefBrowser> browser,
const CefKeyEvent& event,
CefEventHandle os_event,
bool* is_keyboard_shortcut)
{
CEF_REQUIRE_UI_THREAD();
if (event.type == cef_key_event_type_t::KEYEVENT_CHAR)
{
// CTRL+SHIFT+J - bring up the Javascript debugger
if ((event.modifiers == (cef_event_flags_t::EVENTFLAG_CONTROL_DOWN | cef_event_flags_t::EVENTFLAG_SHIFT_DOWN)) && event.unmodified_character == 10 /* j? maybe only on windows? whatever */)
{
CefWindowInfo windowInfo;
CefBrowserSettings settings;
CefPoint point;
windowInfo.SetAsPopup(browser->GetHost()->GetWindowHandle(), "DevTools");
browser->GetHost()->ShowDevTools(windowInfo, browser->GetHost()->GetClient(), settings, point);
return true;
}
// CTRL+F - bring up Find In Page
else if (event.modifiers == cef_event_flags_t::EVENTFLAG_CONTROL_DOWN && event.unmodified_character == 6 /* f? maybe only on windows? whatever */)
{
// probably can do this at some point by ripping off code from the full-fat cefclient, but damn there's a lot of it...
// return true;
}
}
return false;
}
void FCHostHandler::CloseAllBrowsers(bool force_close) {
if (!CefCurrentlyOn(TID_UI)) {
// Execute on the UI thread.
......
......@@ -12,7 +12,8 @@ class FCHostHandler : public CefClient,
public CefDisplayHandler,
public CefLifeSpanHandler,
public CefLoadHandler,
public CefDownloadHandler {
public CefDownloadHandler,
public CefKeyboardHandler {
public:
explicit FCHostHandler(bool use_views);
~FCHostHandler();
......@@ -29,6 +30,7 @@ class FCHostHandler : public CefClient,
}
virtual CefRefPtr<CefLoadHandler> GetLoadHandler() OVERRIDE { return this; }
virtual CefRefPtr<CefDownloadHandler> GetDownloadHandler() OVERRIDE { return this; }
virtual CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() OVERRIDE { return this; }
// CefDisplayHandler methods:
......@@ -57,7 +59,13 @@ class FCHostHandler : public CefClient,
CefRefPtr<CefDownloadItem> download_item,
const CefString& suggested_name,
CefRefPtr< CefBeforeDownloadCallback > callback) OVERRIDE;
// CefKeyboardHandler methods:
virtual bool OnPreKeyEvent(CefRefPtr<CefBrowser> browser,
const CefKeyEvent& event,
CefEventHandle os_event,
bool* is_keyboard_shortcut) OVERRIDE;
// Request that all existing browser windows close.
void CloseAllBrowsers(bool force_close);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment