WebbrowserComponent on Mac not showing


#1

Having a spot of bother with web browser component
I have this below and I console out the url. I override pageAboutToLoad and it says page about to load is google then it gets called again with about black. The component shows. I read somewhere you need to define the allowed urls but not sure how. On mac…

webView = new AdvertComponent();
addAndMakeVisible(webView);
webView->setBounds(0, 0, 500, 300);
webView->goToURL(“https://google.co.uk”);


#2

So I got the NS App Transport settings correct but can’t get this working and tested against the Demo but still this is blank white component

webBrowser =new WebBrowserComponent();
addAndMakeVisible(webBrowser);
webBrowser->setBounds(0,0,400,300);
webBrowser->goToURL("http://nammick.com");

#3

K figured this one as well…

I needed to delay the goToUrl function then it works for some reason…


#4

Yup, not too surprised. Presumably the webkit plugin is ignoring any URL requests until it’s finished initialising.


#5

Cool but is there any anything bool/method that I can key off in my loop to test if WK runs Async. Otherwise it may work fine on my mac but on slower macs it may not initialise. Can’t seem to find anything obvious in the docs

Pseudo method

if(webview->isReady()) {
    webview->goToUrl("http://juce.com");
}

#6

Not really got anything like that, but assuming that it does its initialisation on the message thread, it should be pretty safe to run a timer with a short period like 500ms, because if the webview blocks the message thread while busy, it’ll also delay the timer.


#7

Damm,

Windows not showing WebBrowserComponent but building the demo examples does work perfectly. Is there something similar to App Transport Settings in VS2015 ?

My component is nearly identical to the demo one and I have tried a massively delayed start…


#8

Well spank a doodle doo.

It turns out that in my main.cpp file

mainWindow->setResizable(false,false);

Was messing up WebBrowserComponent somehow. I comment it out and it works…
Is there anyway the WBC can be stopped from inheriting on windows?


#9

“stopped from inheriting”? Not sure what you mean…


#10

I added

    mainWindow = new MainWindow (getApplicationName());
    mainWindow->setResizable(false,false); // this is added to stop window being resizable

in my Main.cpp on an audio app.

This was actually the culprit for stopping the mac WebBrowserComponent working as well as Windows. The work around on mac was the delayed call to goToURL but that didn’t work on windows. So I suspect that sub windows/frames/components to do with WBC are inheriting something from the mainWindow when setResizable is specified.

My question is, Can setResizable be specified on the mainWindow and something to do with WBC be reset so it works like it does before setResizbale is specified.

To recreate the core of the problem just create an Audio App;

in the mainComponent add this with a scopedPointer.

    webView = new WebBrowserComponent();
    addAndMakeVisible(webView);
    webView->setBounds(0, 0, 500, 300);
    webView->goToURL("https://google.co.uk");

And build. Which works fine. Then under

    mainWindow = new MainWindow (getApplicationName());

In Main.cpp add this line

    mainWindow->setResizable(false,false);

And build and the WBC doesn’t work properly.


#11

OK I figured that I shouldn’t be calling setResizable in that way on in the DocumentWindow constructor.