Skip to main content
Version: 12 Dec 2024

MLWebViewEventCallbacks

Module: WebView

Event handler for MLWebView callbacks. More...

#include <ml_webview.h>

Public Attributes

TypeName
uint32_tversion
void *user_data
void()(const char resource_url, void *user_data)on_before_resource_load
Called to notify when a resource will loadeded.
void()(bool is_main_frame, int32_t http_status_code, void user_data)on_load_end
Called to notify load completion.
void()(bool is_main_frame, int32_t http_status_code, const char error_str, const char failed_url, void user_data)on_load_error
Called if there was any error during loading. These errors could be due to connectivity, certificate errors etc.
bool()(int32_t error_code, const char url, const char error_message, const char details, void *user_data)on_certificate_error
Called when there is any certificate error.
void()(int32_t x, int32_t y, int32_t width, int32_t height, int32_t text_input_flags, MLWebViewTextInputType text_input_type, void user_data)on_show_keyboard
Called when user selects an input field.
void()(void user_data)on_keyboard_dismiss
Called when user deselects an input field and the keyboard should be dismissed.
void()(void user_data)on_destroy
Called when webview is destroyed.
void()(void user_data)on_service_connected
This callback is used to pass notify user of service connection.
void()(void user_data)on_service_disconnected
This callback is used to notify user that service is disconnect.
void()(MLResult result, void user_data)on_service_failed
This callback is used to notify user that service has failed.
bool()(const char url, void *user_data)on_before_popup
This callback is used to ask the application if is OK to load a URL.
void()(uint64_t popup_id, const char url, void *user_data)on_popup_opened
This callback is used to notify application that popup is opened.
void()(MLHandle handle, void user_data)on_popup_closed
This callback is used to notify the application of a closing popup.

Detailed Description

struct MLWebViewEventCallbacks;

Event handler for MLWebView callbacks.

This structure must be initialized by calling MLWebViewEventCallbacksInit before use.

API Level:

  • 24

Public Attributes Documentation

version

uint32_t version;

Version of this structure.


user_data

void * user_data;

User data passed to every callback.


on_before_resource_load

void(*)(const char *resource_url, void *user_data) on_before_resource_load;

Called to notify when a resource will loadeded.

TypeDescription
void()(const char resource_url, void *user_data))(const char resource_url, void user_data)

Parameters

resource_urlthe url of the resource about to be loaded.

on_load_end

void(*)(bool is_main_frame, int32_t http_status_code, void *user_data) on_load_end;

Called to notify load completion.

TypeDescription
void()(bool is_main_frame, int32_t http_status_code, void user_data))(bool is_main_frame, int32_t http_status_code, void *user_data)

Parameters

is_main_frameWhether this event was for the main frame.
http_status_codeThe standard http status code.

on_load_error

void(*)(bool is_main_frame, int32_t http_status_code, const char *error_str, const char *failed_url, void *user_data) on_load_error;

Called if there was any error during loading. These errors could be due to connectivity, certificate errors etc.

TypeDescription
void()(bool is_main_frame, int32_t http_status_code, const char error_str, const char failed_url, void user_data))(bool is_main_frame, int32_t http_status_code, const char error_str, const char failed_url, void *user_data)

Parameters

is_main_frameIf this event was for the main frame.
http_status_codeHttp status code for the URL load failure.
error_strThe stringified version of the error code.
failed_urlThe url that caused the load error.

on_certificate_error

bool(*)(int32_t error_code, const char *url, const char *error_message, const char *details, void *user_data) on_certificate_error;

Called when there is any certificate error.

TypeDescription
bool()(int32_t error_code, const char url, const char error_message, const char details, void *user_data))(int32_t error_code, const char url, const char error_message, const char details, void user_data)

Parameters

error_codeError code for ssl error.
urlThe url associated to the certificate error.
error_messageCertificate error short description.
detailsCertificate error details.

Returns

bool()(int32_t error_code, const char url, const char error_message, const char details, void *user_data)Returnstrue if should continue loading and false if should stop loading.

on_show_keyboard

void(*)(int32_t x, int32_t y, int32_t width, int32_t height, int32_t text_input_flags, MLWebViewTextInputType text_input_type, void *user_data) on_show_keyboard;

Called when user selects an input field.

TypeDescription
void()(int32_t x, int32_t y, int32_t width, int32_t height, int32_t text_input_flags, MLWebViewTextInputType text_input_type, void user_data))(int32_t x, int32_t y, int32_t width, int32_t height, int32_t text_input_flags, MLWebViewTextInputType text_input_type, void *user_data)

Parameters

xHorizontal position of the input field.
yVertical position of the input field.
widthWidth of the input field.
heightHeight of the input field.
text_input_flagsOne or combination of MLWebViewTextInputFlags.
text_input_typeOne of MLWebViewTextInputType.

on_keyboard_dismiss

void(*)(void *user_data) on_keyboard_dismiss;

Called when user deselects an input field and the keyboard should be dismissed.

TypeDescription
void()(void user_data))(void *user_data)

on_destroy

void(*)(void *user_data) on_destroy;

Called when webview is destroyed.

TypeDescription
void()(void user_data))(void *user_data)

on_service_connected

void(*)(void *user_data) on_service_connected;

This callback is used to pass notify user of service connection.

TypeDescription
void()(void user_data))(void *user_data)

Parameters

user_dataThe user data passed in during initialization.

on_service_disconnected

void(*)(void *user_data) on_service_disconnected;

This callback is used to notify user that service is disconnect.

TypeDescription
void()(void user_data))(void *user_data)
note

Handle can no longer be used.


on_service_failed

void(*)(MLResult result, void *user_data) on_service_failed;

This callback is used to notify user that service has failed.

TypeDescription
void()(MLResult result, void user_data))(MLResult result, void *user_data)

Parameters

resultThe reason for the failure.
user_dataThe user data passed back to the user.
note

Callback on_service_failed is for version >= 2.


on_before_popup

bool(*)(const char *url, void *user_data) on_before_popup;

This callback is used to ask the application if is OK to load a URL.

TypeDescription
bool()(const char url, void *user_data))(const char url, void user_data)

Parameters

resultThe application should return true if it accepts the popup and false otherwise.
user_dataThe user data passed back to the user.
note

Callback on_before_popup is for version >= 3.


on_popup_opened

void(*)(uint64_t popup_id, const char *url, void *user_data) on_popup_opened;

This callback is used to notify application that popup is opened.

TypeDescription
void()(uint64_t popup_id, const char url, void *user_data))(uint64_t popup_id, const char url, void user_data)

Parameters

user_dataThe user data passed back to the user.
note

Callback on_popup_opened is for version >= 3.


on_popup_closed

void(*)(MLHandle handle, void *user_data) on_popup_closed;

This callback is used to notify the application of a closing popup.

TypeDescription
void()(MLHandle handle, void user_data))(MLHandle handle, void *user_data)

Parameters

handlethe webview handle of the popup being closed
user_dataThe user data passed back to the user.

This callback is used to notify the application of a popup that is being closed. For example, this can happen if window.close() is used. This is not always called. If the application closes the popup itself, then this function is not called. An application should call MLWebViewDestroy as soon as possible on the popup's handle after receiving this callback.