I am creating a WebKit WebView from Vala.
I connected the UserContentManager and registered a script message handler.
I also connected the script_message_received signal before that, as it is writte in the Valadoc documentation.
The script was successfully registered, but script_message_received
does not fire. After executing the script
window.webkit.messageHandlers.test.postMessage ('test');
Nothing happens.
WebView webKit = new WebView ();
webKit = new WebView.with_user_content_manager (new WebKit.UserContentManager ());
webKit.user_content_manager.script_message_received.connect ((js_result) =>
{
debug ("Test result");
});
if (! webKit.user_content_manager.register_script_message_handler ("test"))
debug ("Failed to register script message handler");
What do I have to do so that the signal is fired?
The problem was in
public class Main: Object
You need to use
public class Main: Gtk.Window
Otherwise nothing works.