Events
This page documents various webview events
Available Events
Section titled “Available Events”This event is emitted when a web-page requests a permission.
webview->on<saucer::webview::event::permission>([](const std::shared_ptr<saucer::permission::request>&) -> saucer::status { // ...});The request holds the following information:
-
request->uri()The web-page that initiated this request
-
request->type()The type (
saucer::permission::type) of the permission request. This can be one (or a combination) of the following:- unknown
- audio_media
- video_media
- desktop_media
- mouse_lock
- device_info
- location
- clipboard
- notification
Subscribers of this event can accept (request->accept(true)) or deny (request->accept(false)) this request.
In case the request is ignored, it will be denied by default.
This event is emitted when a web-page tries to go into fullscreen.
webview->on<saucer::webview::event::fullscreen>([](bool fullscreened) -> saucer::policy { // ...});Subscribers of this event can block fullscreening by returning saucer::policy::block or allow fullscreening by returning saucer::policy::allow.
This event is emitted when the DOM is ready.
webview->on<saucer::webview::event::dom_ready>([]() { // ...});This event is emitted when a navigation finishes.
webview->on<saucer::webview::event::navigated>([](const saucer::uri&) { // ...});This event is emitted when a navigation is started / requested.
webview->on<saucer::webview::event::navigate>([](const saucer::navigation&) -> saucer::policy { // ...});The navigation request holds the following information:
-
request->url()The requested URL
-
request->new_window()Whether or not the request wants to open a new window
-
request->redirection()Whether or not the request was initiated by a redirection
-
request->user_initiated()Whether or not the request was user initiated
This event is emitted when an RPC message is sent.
webview->on<saucer::webview::event::message>([](std::string_view) -> saucer::status { // ...});If the message was handled successfully, saucer::status::handled should be returned.
Otherwise, saucer::status::unhandled should be returned to allow other subscribers to try and handle this event.
This event is emitted when a web-resource is requested.
webview->on<saucer::webview::event::request>([](const saucer::uri&) { // ...});This event is emitted when a websites favicon was loaded.
webview->on<saucer::webview::event::favicon>([](const saucer::icon&) { // ...});The loaded icon will be passed as a function parameter. It is possible to inspect the raw-bytes of the icon or save it to disk.
This event is emitted when the title of a web-page changes.
webview->on<saucer::webview::event::title>([](std::string_view) { // ...});This event is emitted when the loading state of the web-page changes.
webview->on<saucer::webview::event::load>([](const saucer::state&) { // ...});The state can be one of the following:
saucer::state::startedsaucer::state::finished