WebBrowserComponent not getting mouse/key events


#1

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


#2

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


#3

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).


#4

Ah yes, that’ll screw it.


#5

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


#6

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)


#7

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

BUT

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.


#8

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…


#9

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.


#10

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 ?


#11

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.


#12

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.

#13

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?


#14

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).


#15

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.


#16

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"),
											 _pWebBrowserComponent(0L)
{
	_sCartUrl = sCartUrl;
}

Cart::~Cart()
{
	SAFE_DELETE(_pWebBrowserComponent);
}

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();
		addChildComponent(_pWebBrowserComponent);
		_pWebBrowserComponent->setBounds(5, 0, getWidth() -5,  getHeight()- 20);
	}
	
	if (_pWebBrowserComponent != 0L)
	{
		_pWebBrowserComponent->setVisible (true);
		_pWebBrowserComponent->goToURL(_sCartUrl);
	}
	resized();
}

void Cart::UnLoadWebBrowser()
{
	if(_pWebBrowserComponent)
	{
		_pWebBrowserComponent->setBounds(0,0,0,0);
		_pWebBrowserComponent->setVisible(false);
	}
}

#17

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.


#18

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

source
binary


#19

Ok, will take a look asap.


#20

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…