diff --git a/FCHost/fchost/fchost_handler.cc b/FCHost/fchost/fchost_handler.cc index 20ca89674348e8e3098edafe95afb9255c3fcdf7..33586d050ea421cf7836d55437b380041bd1a8bb 100644 --- a/FCHost/fchost/fchost_handler.cc +++ b/FCHost/fchost/fchost_handler.cc @@ -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. diff --git a/FCHost/fchost/fchost_handler.h b/FCHost/fchost/fchost_handler.h index c4288392505af64b9070d8c2226e999abacea8a7..940d0348458dd406d018509cac3c1707fa2e4a37 100644 --- a/FCHost/fchost/fchost_handler.h +++ b/FCHost/fchost/fchost_handler.h @@ -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);