Forum Archive

Webview delegate - webview_should_start_load not being called

rkeir

I'm using a ui WebView with delegate function 'webview_did_finish_load' being called successfully, but the delegate function 'webview_should_start_load' just doesn't seem to get called at all, whatever I do. Has anybody had any luck with this?

If it makes any difference the WebView is initially populated through load_html() as opposed to load_url(), but the function is not called even when navigating away to real sites.

omz

Did you copy the method declaration from the documentation? Unfortunately, I forgot the self parameter there, so the method has the incorrect number of arguments. It should look like this:

class MyWebViewDelegate (object):
    def webview_should_start_load(self, webview, url, nav_type):
        # do something...
        return True
rkeir

Agh! It was staring right at me! You're absolutely right. I had missed the self parameter after copy/paste from the docs (to save typing). I did of course have the self parameter for the working web_did_finish_load function.

Thanks, and congratulations on a fantastic app.