Hi,
if you have a WebBrowserComponent (windows) in an initially hidden container it fails to work.
The code below contains a fully working example of the bug.
#ifndef __MAINCOMPONENT_H_5B20A610__
#define __MAINCOMPONENT_H_5B20A610__
#include "../JuceLibraryCode/JuceHeader.h"
class WebBrowserContainerComponent : public Component
{
public:
WebBrowserContainerComponent()
{
addAndMakeVisible(m_WebBrowser = new WebBrowserComponent(false));
m_WebBrowser->setBounds(0, 0, 400, 500);
}
ScopedPointer<WebBrowserComponent> m_WebBrowser;
};
class MainContentComponent : public Component, public Button::Listener
{
public:
//==============================================================================
MainContentComponent()
{
addAndMakeVisible(m_Button = new TextButton());
m_Button->setButtonText("Click me!");
m_Button->setBounds(10, 10, 100, 20);
m_Button->addListener(this);
addAndMakeVisible(m_WebBrowser1 = new WebBrowserComponent(false));
m_WebBrowser1->setBounds(0, 40, 400, 500);
m_WebBrowser1->goToURL("http://www.google.com");
addAndMakeVisible(m_WebBrowser2 = new WebBrowserContainerComponent());
m_WebBrowser2->setBounds(400, 40, 400, 500);
//uncomment the next line to see the problem!
//m_WebBrowser2->setVisible(false);
setSize (800, 600);
}
void buttonClicked(Button* button)
{
m_WebBrowser2->setVisible(true);
m_WebBrowser2->m_WebBrowser->goToURL("http://www.google.com");
}
private:
ScopedPointer<WebBrowserComponent> m_WebBrowser1;
ScopedPointer<WebBrowserContainerComponent> m_WebBrowser2;
ScopedPointer<TextButton> m_Button;
//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainContentComponent)
};
#endif // __MAINCOMPONENT_H_5B20A610__
As the webbrowser component fails to work in a modal window (see some other thread…) so I need to show it non-modal. But… I need to hide this non-modal window at startup, and that fails. I will work around the problem by CREATING the component when I need it instead of hiding it at the start, but I thought this was a pesky little bug that could probably solved by relatively simple logic…
- Bram