Devtools show but cannot interact

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.

Devtools show but cannot interact

Postby codetemplar » Wed Jun 15, 2016 10:13 am

Hi all,

I am using CEF with c++ visual studio 2013. I have hooked up CEF with my application successfully and can use it to load a HTML5 game that I created. It handles mouse clicks fine. I have added a key hook to my application so when I press a key it will show the dev tools dialogue on the screen for me to debug the game. It loads and shows the dev tools fine but does not accept any mouse clicks for me to navigate with. Mouse clicking works in the rest of game using SendMouseClickEvent on the browser host.

When I create and initialise CEF I store the browserSettings and WindowSettings so I can reuse them as the parameters to ShowDevTools.

To initialise cef and to show in my game window I simply do: (this is a cut down version, I've stripped out everything that is irrelevant. Please note my game has multiple screens, hence the map)
Code: Select all
         struct WindowData
         {
            CefRefPtr<CefBrowser> m_browser;
            CefRefPtr<BrowserEventHandler> m_browserClient;
            CefWindowInfo m_window_info;
            CefBrowserSettings m_browserSettings;
            CefRefPtr<ClientApp> m_clientApp;
         };

         std::map<std::string, WindowData> m_windowData;

         WindowData wd ;
         CefMainArgs args;
         wd.m_clientApp = CefRefPtr<ClientApp>(new ClientApp);
         CefExecuteProcess(args, wd.m_clientApp.get(), nullptr);
         CefSettings settings;
         settings.single_process = true;
         CefInitialize(args, settings, wd.m_clientApp.get(), nullptr);
         wd.m_browserSettings.javascript = STATE_ENABLED;
         wd.m_browserSettings.caret_browsing = STATE_ENABLED;
         wd.m_browserSettings.tab_to_links = STATE_ENABLED;
         wd.m_browserSettings.web_security = STATE_DISABLED;
         wd.m_browserSettings.universal_access_from_file_urls = STATE_ENABLED;
         wd.m_browserSettings.file_access_from_file_urls = STATE_ENABLED;
         
         std::size_t windowHandle = getWindowHandle("Screen1");
         wd.m_window_info.SetAsWindowless((HWND)windowHandle, false);

         wd.m_browserClient = new BrowserEventHandler();

         std::string url = "http://www.google.com";
         wd.m_clientApp->m_browser = CefBrowserHost::CreateBrowserSync(wd.m_window_info, wd.m_browserClient.get(), url.c_str(), wd.m_browserSettings, nullptr);
         wd.m_clientApp->m_browser->GetHost()->SendFocusEvent(true);

m_windData["Screen1"] = wd;



Then inside my keyevent callback I simply do:

Code: Select all

//show dev tools
if (keyPressed == 'a') // show dev tools
{
WindowData wd = m_windowData["Screen1"];
m_browser->GetHost()->ShowDevTools(wd.m_window_info, wd.m_browserClient.get(), wd.m_browserSettings, CefPoint());
}


This successfully shows the devtools page over the google page but it doesn't respond to mouse clicks when google did.

Just for completeness my mouse click handler looks like so:

Code: Select all

void RenderHandler::OnClick(int x, int y, bool up)
      {
         CefMouseEvent me;
         me.x = x;
         me.y = y;
         m_browser->GetHost()->SendMouseClickEvent(me, MBT_LEFT, up, 1);
      }




Thanks for any help

Edit: please note, that I am rendering this inside a game engine by rendering to texture. The idea was to use the same browser object to show the dev tools inside the game window rather than having a separate pop-up to show the dev tools like cef-project. Not sure if this is what's causing it. Perhaps the mouse clicks are not getting sent to the dev tools browser like I thought due to this.
codetemplar
Newbie
 
Posts: 5
Joined: Thu Feb 25, 2016 3:25 pm

Re: Devtools show but cannot interact

Postby magreenblatt » Wed Jun 15, 2016 12:33 pm

DevTools is a separate browser. Are you sending mouse/keyboard events to that browser?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Devtools show but cannot interact

Postby codetemplar » Wed Jun 15, 2016 12:47 pm

No I guess I'm not doing that lol.

What I do is when I press the keyboard I get the browser that is currently showing/running my JavaScript game. I then get the host of this browser and call ShowDevTools on this. The parameters i pass to dev tools (the window_info, browser settings, browser client) are the same as the ones that are associated with the main browser.

Does ShowDevTools create it's own browser internally that I should be sending mouse events to? If so how do I get this browser once I called ShowDevTools?

Thanks for your help :)
codetemplar
Newbie
 
Posts: 5
Joined: Thu Feb 25, 2016 3:25 pm

Re: Devtools show but cannot interact

Postby magreenblatt » Wed Jun 15, 2016 12:52 pm

codetemplar wrote:how do I get this browser once I called ShowDevTools?

You pass a CefClient instance to ShowDevTools(). The resulting CefBrowser is then passed passed to CefLifeSpanHandler::OnAfterCreated() retrieved via the CefClient.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

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