WebBrowserComponent not getting mouse/key events

It loads a web page, i can change the locations using the calls provided in the component, but the component does not react to mose clicks on the web page or any keyboard events in it. If i click a text input box in it, it never gets focus. When i hover my mouse over the webpage the cursor changes (hand/beam depending on the location on the page). I can’t scroll it (the native OS scrollbars are visible). The whole component consists of a toolbar and the webbrowser component below it, it’s created in JUCE

I’m on Windows 7, VS2008 with SP1, Debug build, latest juce tip from GIT

Probably something broken in IE8. I’m not on windows 7 yet so haven’t tested the webbrowser in it yet…

well it’s weird, when i compile the Juce Demo it works fine, when i use it in my application it does not.

I’m placing my web browser component in a modal dialog, that’s the only difference (as far as i can notice).

Ah yes, that’ll screw it.

Hi Jules,
Does that means WebBrowserComponent can’t be placed in a modal component(on both mac and pc)?

Well, you’d be ok unless you want the user to be able to interact with it. The problem is that when a juce comp is modal, it prevents events getting sent to windows that it doesn’t know about, and since the browser window is foreign, it doesn’t know that it should still be allowed to get events.

It might be possible to fix it, but I’ve no time to look at it right now.

(and on the mac it might be ok, actually)

ok i switched to non-modal window.

but now a weird error occures. i add my toolbar+browser component as a tab in a TabbedComponent. When i add this component while my application is running, i get grey background instead of the actual web browser, also all those threads that IE creates are not created


i save the state of my component, and when i re-open my application and do the same procedure of adding saved tabs, the component appears like a normal component and works

Also if I add two tabs with the same component, close and open the application only one tab has the proper WebBrowser component, the other is grey.

This is Windows XP and VS2008.

Must be that the activexcomponent isn’t realising that it’s on-screen and needs to instantiate the activex object.

Probably because it’s already visible, but inside an off-screen comp which is then added… though all that sort of stuff should be handled correctly. Hmm…

I have seen similar issues, but realized later that when ActiveXcomponent was initialized the component on which I was placing it was not visible. In which case web-browser won’t be shown.

so i can’t have to instances of the WebBrowser ?

i was looking into WebKit and QT and the component they offer (QTWebKit), maybe this could be a way out on all platforms ?

of course you can. What made you think otherwise?

I don’t know why you’re looking around for other solutions - the juce browser works just fine - it’ll just be the order in which you add the component/make it visible that’s confusing the ActiveXComp, and making it forget to instanciate the control.

Hi atom,
Correct me if I am wrong. You are adding webbrowsercomponent to the tab component and after that adding tab component to your application.

 While using webbrowsercomponent the order in which the webbrowsercomponent is added is important. If the webbrowsercomponent is added before the tab component is visible, the webbrowsercomponent wouldn't show up.

allright in that case, i’ll look into visibility changes calls and see if that will work.

i have a tabbed component, one tab (some other component) and a button that adds a new one, the new one is the web browser, the tab is added invisible so the web browser is not visible.

if i understood this right, i need to first make the tab viisble and then add the web browser component?

Well i tested this, it’s better, but when i switch the tab to some other and go back the component is all white (the native os popup menu works, the scrollbars are there but the webpage is all white).

Well I will post my code soon. The problem with Webbrowsercomponent is that it doesn’t behave like a normal juce component.

I normally put webbrowsercomponent inside juce component and add two methods for loading and unloading the webbrowsercomponent.

When I unload the webbrowsercomponent, I set the visibility of webbrowsercomponent to false and set bounds to 0 and on load I set proper bonds for it.

Hopefully this would be of some help

Filename:    Cart.cpp

Author:      Vishvesh D Kumar

Created:     13 July 2009		

Description: Holds the webBrowserComponent.

#include "Cart.h"

Cart::Cart (juce::String &sCartUrl):juce::Component("Component"),
	_sCartUrl = sCartUrl;


void Cart::resized()
	if ( _pWebBrowserComponent != 0L )
		_pWebBrowserComponent->setBounds(4, 4, getWidth() - 8, getHeight() - 8);

// it is called only after the component holding cart is visible. 
void Cart::LoadBrowser()
	if (_pWebBrowserComponent == 0L)
		_pWebBrowserComponent = new juce::WebBrowserComponent();
		_pWebBrowserComponent->setBounds(5, 0, getWidth() -5,  getHeight()- 20);
	if (_pWebBrowserComponent != 0L)
		_pWebBrowserComponent->setVisible (true);

void Cart::UnLoadWebBrowser()

I’ve tried to make the web component as robust as I can, but it’s hard to catch every case.

If you can find a case where it doesn’t work and can send me some sample code that reproduces the problem, I’ll be happy to take a look and try to make it deal with that situation.

Ok here is my code, that does not work (it’s a VS2008 project very simple but demonstrates the problem).

A win32 release binary too


Ok, will take a look asap.

Ok, this just required a slight tweak to make it reload the page when the browser’s parent is made visible. Thanks for the sample app - I’ll check in a fix later today…