The webview will automatically emit the following events (and intentions) during its lifecycle.
To subscribe to events, you can use direct access to the event listener.
$webview = $app->webview; $webview->addEventListener(Event::class, function (Event $e): void { var_dump($e); });
The webview instance also supports a more convenient and simple way of
registering events using the on()
method.
$webview->on(function (Event $event): void { var_dump($event); });
More information about events can be found in the event documentation.
#Dom Ready Event
An Boson\WebView\Event\WebViewDomReady
event fired after webview DOM has been
loaded and ready to work.
class WebViewDomReady<WebView>
#Favicon Changing Intention
An Boson\WebView\Event\WebViewFaviconChanging
intention to change the
window's icon from loaded HTML content.
Linux/GTK4
An intention does not change the windows icon.
Icon change intention has no effect.
macOS/WebKit
Provides no way to access favicons.
Icon change intention has no effect.
class WebViewFaviconChanging<WebView>
If intention is cancelled, the window icon has not been changed.
#Favicon Changed Event
An Boson\WebView\Event\WebViewFaviconChanged
event fired after the window's
icon has been changed and the Boson\WebView\Event\WebViewFaviconChanging
intention has not been cancelled.
class WebViewFaviconChanged<WebView>
#Message Received Event
An Boson\WebView\Event\WebViewMessageReceived
intention to
receive message
from the webview.
class WebViewMessageReceived<WebView> { public readonly string $message; public function ack(): void; }
$message
- Received message string value.
The
ack()
method marks the message as accepted and processed.
The
stopPropagation()
method works in a similar way toack()
, but is not recommended due semantic conflicts.
#Navigating Intention
An Boson\WebView\Event\WebViewNavigating
intention to change the
webview's URL (navigating to passed URL).
class WebViewNavigating<WebView> { public readonly string $url; public readonly bool $isNewWindow; public readonly bool $isRedirection; public readonly bool $isUserInitiated; }
$url
- The URL address by which navigation occurs.$isNewWindow
- Navigation to the specified URL should have been made in a new window.$isRedirection
- Navigation to the specified URL occurs using a redirect.$isUserInitiated
- Navigation to the specified URL does not occur automatically, but is initialized by the user.
If intention is cancelled, the URL navigation will be cancelled.
#Navigated Event
An Boson\WebView\Event\WebViewNavigated
event fired after the webview has been
navigated to the given URL and the Boson\WebView\Event\WebViewNavigating
intention has not been cancelled.
class WebViewNavigated<WebView> { public readonly string $url; }
$url
- The URL address by which navigation occurs.
#Title Changing Intention
An Boson\WebView\Event\WebViewTitleChanging
intention to change the
window title from loaded HTML content.
class WebViewTitleChanging<WebView> { public readonly string $title; }
$title
- Expected title string to be set.
If intention is cancelled, then the window title has not been changed.
#Title Changed Event
An Boson\WebView\Event\WebViewTitleChanged
event fired after window title has
been changed and the Boson\WebView\Event\WebViewTitleChanging
intention has not been cancelled.
class WebViewTitleChanged<WebView> { public readonly string $title; }
$title
- Title string from the HTML content of the webview.