Skip to main content
Version: 20 Mar 2024

NativeBindings

See ml_webview.h for additional comments.

Inherits from:
MagicLeapNativeBindings

Public Methods

IntPtr GetAppContext

Returns pointer to App Context that is required by WebView API.

public IntPtr GetAppContext()

Returns: pointer to JavaVM


IntPtr GetJavaVM

Returns pointer to JavaVM that is required by WebView API.

public IntPtr GetJavaVM()

Returns: pointer to JavaVM


MLResult.Code MLWebViewAcquireNextAvailableFrame

Acquires next available frame buffer for rendering.

public MLResult.Code MLWebViewAcquireNextAvailableFrame(
ulong handle,
out IntPtr hwBuffer
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.
out IntPtrbufferHandleThe buffer that is ready to be rendered. A value of 0 indicates no frame is ready.

Returns: MLResult.Code.Ok if frame is ready.

MLResult.Code.InvalidParam if its nable to find the specified MLWebView handle.

MLResult.Code.Pending if the MLWebView handle is not ready to use.


MLResult.Code MLWebViewCanGoBack

Checks if the "Back" action is currently valid.

public MLResult.Code MLWebViewCanGoBack(
ulong handle,
out bool outCanGoBack
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.
out booloutCanGoBackTrue if "Back" has a valid page to go to.

Returns: MLResult.Code.Ok if status of going "Back" was acquired.

MLResult.Code.IllegalState if WebView was paused. See MLWebViewPause.

MLResult.Code.InvalidParam if its unable to find the specified MLWebView handle.

MLResult.Code.Pending if the MLWebView handle is not ready to use.


MLResult.Code MLWebViewCanGoForward

Checks if the "Forward" action is currently valid.

public MLResult.Code MLWebViewCanGoForward(
ulong handle,
out bool outCanGoForward
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.
out booloutCanGoForwardTrue if "Forward" has a valid page to go to.

Returns: MLResult.Code.Ok if status of going "Forward" was acquired.

MLResult.Code.InvalidParam if its unable to find the specified MLWebView handle.

MLResult.Code.Pending if the MLWebView handle is not ready to use.


MLResult.Code MLWebViewClearCache

Clear the webview cache.

public MLResult.Code MLWebViewClearCache(
ulong handle
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.

Returns: MLResult.Code.Ok if cache cleared successfully

MLResult.Code.IllegalState if WebView was paused. See MLWebViewPause.

MLResult.Code.InvalidParam if its unable to find the specified MLWebView handle.

MLResult.Code.UnspecifiedFailure if clearing cache failed due to an internal error.

MLResult.Code.Pending if the MLWebView handle is not ready to use.


MLResult.Code MLWebViewCreate

Create a MLWebView. The MLWebView will be ready to use once this function returns with MLResult_OK.

public MLResult.Code MLWebViewCreate(
out ulong handle,
ref Settings settings
)

Parameters

TypeNameDescription
out ulonghandleHandle that is ready to use with all other MLWebView API calls.
ref SettingssettingsThe initialization paramaters for the webview.

Returns: MLResult.Code.Ok if the MLWebView is ready for use.

MLResult.Code.UnspecifiedFailure if Unable to create the MLWebView.

MLResult.Code.InvalidParam if the parameter was null pointer.

MLResult.Code.PermissionDenied its missing the permission(s).


MLResult.Code MLWebViewDestroy

Destroy a MLWebView. The MLWebView will be terminated by this function call and the handle shall no longer be valid.

public MLResult.Code MLWebViewDestroy(
ulong handle
)

Parameters

TypeNameDescription
ulonghandle

Returns: MLResult.Code.Ok if was destroyed successfully.

MLResult.Code.UnspecifiedFailure if an error occurred destroying the MLWebView.

MLResult.Code.InvalidParam if its unable to find the specified MLWebView handle.


MLResult.Code MLWebViewGetFrameTransformMatrix

Retrieves the 4x4 texture coordinate transform matrix used by all MLWebView frames. This transform matrix maps 2D homogeneous texture coordinates of the form (s, t, 0, 1) with s and t in the inclusive range [0, 1] to the texture coordinate that should be used to sample that location from the texture. Sampling the texture outside of the range of this transform is undefined. The matrix is stored in column-major order so that it may be passed directly to OpenGL ES via the glLoadMatrixf or glUniformMatrix4fv functions.

public MLResult.Code MLWebViewGetFrameTransformMatrix(
ulong handle,
out MLMat4f outMtx
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.
out MLMat4foutMtxThe retrieved matrix.

Returns: MLResult.Code.Ok if constant matrix was retrieved.

MLResult.Code.Pending if the MLWebView handle is not ready to use.


MLResult.Code MLWebViewGetScrollOffset

Get the scroll offset of the webview.

public MLResult.Code MLWebViewGetScrollOffset(
ulong handle,
out int x,
out int y
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.
out intxThe number representing the horizontal offset of the webview, in pixels.
out intyThe number representing the vertical offset of the webview, in pixels.

Details*

TODO: To be removed due to deprecation.

Returns: MLResult.Code.Ok if MLWebView scroll offset values were retrieved.

MLResult.Code.IllegalState if WebView was paused. See MLWebViewPause.

MLResult.Code.Pending if the MLWebView handle is not ready to use.


MLResult.Code MLWebViewGetScrollSize

Get the entire scrollable size of the webview. This should be typically called afer HandleOnLoadEnd to determine the scollable size of the main frame of the loaded page.Some pages might dynamically resize and this should be called before each frame draw to correctly determine the scrollable size of the webview.

public MLResult.Code MLWebViewGetScrollSize(
ulong handle,
out int width,
out int height
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.
out intwidthThe number representing the entire width of the webview, in pixels.
out intheightThe number representing the entire height of the webview, in pixels.

Details*

TODO: To be removed due to deprecation.

Returns: MLResult.Code.Ok if MLWebView scroll size values were retrieved.

MLResult.Code.IllegalState if WebView was paused. See MLWebViewPause.

MLResult.Code.Pending if the MLWebView handle is not ready to use.


MLResult.Code MLWebViewGetUrl

Get the current URL. Set outUrl to NULL to get the length of the current URL.

public MLResult.Code MLWebViewGetUrl(
ulong handle,
out uint inoutSize,
IntPtr outUrl
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.
out uintinoutSizeThe size that has been allocated in outUrl to hold the URL. This will be set to the actual length of URL if inoutSize and size needed for the URL are different.
IntPtroutUrlThe URL up to inoutSize of characters.

Returns: MLResult.Code.Ok if WebView URL was acquired.

MLResult.Code.InvalidParam if its unable to find the specified MLWebView handle.

MLResult.Code.Pending if the MLWebView handle is not ready to use.


MLResult.Code MLWebViewGetZoomFactor

Get the current zoom factor. The default zoom factor is 1.0.

public MLResult.Code MLWebViewGetZoomFactor(
ulong handle,
out double outZoomFactor
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.
out doubleoutZoomFactorCurrent numeric value for zoom factor.

Returns: MLResult.Code.Ok if outZoomFactor parameter was updated with the current zoom value.

MLResult.Code.IllegalState if WebView was paused. See MLWebViewPause.

MLResult.Code.InvalidParam if its unable to find the specified MLWebView handle.

MLResult.Code.UnspecifiedFailure if failed to get the zoom factor due to an internal error.

MLResult.Code.Pending if the MLWebView handle is not ready to use.


MLResult.Code MLWebViewGoBack

Trigger a "Back" action in the MLWebView. Query MLWebViewCanGoBack before calling this method. If there is no valid page to go back to, this method will be no-op.

public MLResult.Code MLWebViewGoBack(
ulong handle
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.

Returns: MLResult.Code.Ok if WebView Back action was initiated or cannot go back any further.

MLResult.Code.IllegalState if WebView was paused. MLWebViewResume should be called before this function.

MLResult.Code.InvalidParam if its unable to find the specified MLWebView handle.

MLResult.Code.Pending if the MLWebView handle is not ready to use.


MLResult.Code MLWebViewGoForward

Trigger a "Forward" action in the MLWebView. Query #MLWebViewCanGoForward before calling this method. If there is no valid page to go forward to, this method will be no-op.

public MLResult.Code MLWebViewGoForward(
ulong handle
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.

Returns: MLResult.Code.Ok if WebView Forward action was initiated or cannot go forward any further.

MLResult.Code.IllegalState if WebView was paused. MLWebViewResume should be called before this function.

MLResult.Code.InvalidParam if its unable to find the specified MLWebView handle.

MLResult.Code.Pending if the MLWebView handle is not ready to use.


MLResult.Code MLWebViewGoTo

Go to a URL with the specified MLWebView. Note that success with this call only indicates that a load will be attempted. Caller can be notified about issues loading the URL via the event handler on_load_error.

public MLResult.Code MLWebViewGoTo(
ulong handle,
string url
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.
stringurlURL that will be loaded.

Returns: MLResult.Code.Ok if WebView is attempting to load the specified URL.

MLResult.Code.IllegalState if WebView was paused. MLWebViewResume should be called before this function.

MLResult.Code.InvalidParam if its unable to find the specified MLWebView handle.

MLResult.Code.Pending if the MLWebView handle is not ready to use.


MLResult.Code MLWebViewInjectChar

Sends a printable char keyboard event to MLWebView.

public MLResult.Code MLWebViewInjectChar(
ulong handle,
uint charUtf32
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.
uintcharUtf32printable char utf code

Returns: MLResult.Code.Ok if key event was injected.

MLResult.Code.IllegalState if WebView was paused. See MLWebViewPause.

MLResult.Code.InvalidParam if its unable to find the specified MLWebView handle.

MLResult.Code.Pending if the MLWebView handle is not ready to use.


MLResult.Code MLWebViewInjectKeyDown

Sends a key down/pressed event to MLWebView.

public MLResult.Code MLWebViewInjectKeyDown(
ulong handle,
MLWebView.KeyCode keyCode,
uint modifierMask
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.
MLWebView.KeyCodekeyCodeMLWebView.KeyCode.
uintmodifierMaskShould be one or combination of MLWebView.EventFlags.

Returns: MLResult.Code.Ok if key event was injected.

MLResult.Code.IllegalState if WebView was paused. See MLWebViewPause.

MLResult.Code.InvalidParam if its unable to find the specified MLWebView handle.

MLResult.Code.Pending if the MLWebView handle is not ready to use.


MLResult.Code MLWebViewInjectKeyUp

Sends a key up/release event to MLWebView.

public MLResult.Code MLWebViewInjectKeyUp(
ulong handle,
MLWebView.KeyCode keyCode,
uint modifierMask
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.
MLWebView.KeyCodekeyCodeMLWebView.KeyCode.
uintmodifierMaskShould be one or combination of MLWebView.EventFlags.

Returns: MLResult.Code.Ok if key event was injected.

MLResult.Code.IllegalState if WebView was paused. See MLWebViewPause.

MLResult.Code.InvalidParam if its unable to find the specified MLWebView handle.

MLResult.Code.Pending if the MLWebView handle is not ready to use.


MLResult.Code MLWebViewInjectMouseButtonDown

Sends a mouse button down/pressed event on a specific location on screen.

public MLResult.Code MLWebViewInjectMouseButtonDown(
ulong handle,
ref CursorState cursorState
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.
ref CursorStatecursorStateInformation about the mouse button event.

Returns: MLResult.Code.Ok if successful.

MLResult.Code.IllegalState if WebView was paused. See MLWebViewPause.

MLResult.Code.InvalidParam if its unable to find the specified MLWebView handle.

MLResult.Code.Pending if the MLWebView handle is not ready to use.


MLResult.Code MLWebViewInjectMouseButtonUp

Sends a mouse button up/released event on a specific location on screen.

public MLResult.Code MLWebViewInjectMouseButtonUp(
ulong handle,
ref CursorState cursorState
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.
ref CursorStatecursorStateInformation about the mouse button event.

Returns: MLResult.Code.Ok if successful.

MLResult.Code.IllegalState if WebView was paused. See MLWebViewPause.

MLResult.Code.InvalidParam if its unable to find the specified MLWebView handle.

MLResult.Code.Pending if the MLWebView handle is not ready to use.


MLResult.Code MLWebViewInjectMouseMove

Moves the WebView mouse.

public MLResult.Code MLWebViewInjectMouseMove(
ulong handle,
ref CursorState cursorState
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.
ref CursorStatecursorStateInformation about the mouse movement.

Returns: MLResult.Code.Ok if internal mouse was moved.

MLResult.Code.IllegalState if WebView was paused. See MLWebViewPause.

MLResult.Code.InvalidParam if its unable to find the specified MLWebView handle.

MLResult.Code.Pending if the MLWebView handle is not ready to use.


MLResult.Code MLWebViewPause

Pause the webview. Call MLWebViewResume to resume. This method provides a multiple pause types to the webview.

public MLResult.Code MLWebViewPause(
ulong handle,
MLWebView.PauseType pauseType
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.
MLWebView.PauseTypepauseTypeThe type of pause to be used.

Returns: MLResult.Code.Ok if paused successfully.

MLResult.Code.InvalidParam if its unable to find the specified MLWebView handle or PauseType value.

MLResult.Code.UnspecifiedFailure if failed due to an internal error.

MLResult.Code.Pending if the MLWebView handle is not ready to use. See an asynchronous mode of MLWebViewCreate.


MLResult.Code MLWebViewReleaseFrame

Release a frame acquired by #MLWebViewAcquireNextAvailableFrame.

public MLResult.Code MLWebViewReleaseFrame(
ulong handle,
IntPtr hwBuffer
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.<
IntPtrbufferHandleThe frame being released.

Returns: MLResult.Code.Ok if frame was successfully released.

MLResult.Code.UnspecifiedFailure if error occurred releasing the frame.

MLResult.Code.InvalidParam if its unable to find the specified MLWebView handle.

MLResult.Code.Pending if the MLWebView handle is not ready to use.


MLResult.Code MLWebViewReload

Trigger a "Reload" action in the MLWebView.

public MLResult.Code MLWebViewReload(
ulong handle
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.

Returns: MLResult.Code.Ok if WebView Reload action was initiated.

MLResult.Code.IllegalState if WebView was paused. MLWebViewResume should be called before this function.

MLResult.Code.InvalidParam if its unable to find the specified MLWebView handle.

MLResult.Code.Pending if the MLWebView handle is not ready to use.


MLResult.Code MLWebViewRemoveAllCookies

Remove all webview cookies.

public MLResult.Code MLWebViewRemoveAllCookies(
ulong handle
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.

Returns: MLResult.Code.Ok if all cookies removed successfully.

MLResult.Code.IllegalState if WebView was paused. See MLWebViewPause.

MLResult.Code.InvalidParam if its unable to find the specified MLWebView handle.

MLResult.Code.UnspecifiedFailure if removing all cookies failed due to an internal error.

MLResult.Code.Pending if the MLWebView handle is not ready to use.


MLResult.Code MLWebViewResetZoom

Reset zoom level to 1.0.

public MLResult.Code MLWebViewResetZoom(
ulong handle
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.

Returns: MLResult.Code.Ok if MLWebView zoom was reset.

MLResult.Code.IllegalState if WebView was paused. See MLWebViewPause.

MLResult.Code.InvalidParam if its unable to find the specified MLWebView handle.

MLResult.Code.UnspecifiedFailure if it failed to reset zoom due to an internal error.

MLResult.Code.Pending if the MLWebView handle is not ready to use.


MLResult.Code MLWebViewResume

Resumes a webview after a previous call of the MLWebViewPause. Resume webview to the normal operation for all webview pause types.

public MLResult.Code MLWebViewResume(
ulong handle
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.

Returns: MLResult.Code.Ok if resumed successfully.

MLResult.Code.IllegalState if WebView was paused. See MLWebViewPause.

MLResult.Code.InvalidParam if its unable to find the specified MLWebView handle.

MLResult.Code.UnspecifiedFailure if failed due to an internal error.

MLResult.Code.Pending if the MLWebView handle is not ready to use. See an asynchronous mode of MLWebViewCreate.


MLResult.Code MLWebViewScrollBy

Triggers a mouse "Scroll" event.

public MLResult.Code MLWebViewScrollBy(
ulong handle,
uint xPixels,
uint yPixels
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.
uintxPixelsThe number of pixels to scroll on the x axis.
uintyPixelsThe number of pixels to scroll on the y axis.

Returns: MLResult.Code.Ok if MLWebView was scrolled.

MLResult.Code.IllegalState if WebView was paused. See MLWebViewPause.

MLResult.Code.InvalidParam if its unable to find the specified MLWebView handle.

MLResult.Code.Pending if the MLWebView handle is not ready to use.


MLResult.Code MLWebViewSetEventCallbacks

Specify the event handler for an MLWebView.

public MLResult.Code MLWebViewSetEventCallbacks(
ulong handle,
EventCallbacks callbacks,
IntPtr userData
)

Parameters

TypeNameDescription
ulonghandleThe MLWebView to link the event handler.
EventCallbackscallbacksThe event handler to link to the MLWebView.
IntPtruserDataData that will be passed to your event handler when triggered.

Returns: MLResult.Code.Ok if event handler was set.

MLResult.Code.InvalidParam if its unable to find the specified MLWebView handle.

MLResult.Code.Pending if the MLWebView handle is not ready to use.


MLResult.Code MLWebViewZoomIn

Zoom in one level.

public MLResult.Code MLWebViewZoomIn(
ulong handle
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.

Returns: MLResult.Code.Ok if MLWebView zoomed in.

MLResult.Code.IllegalState if WebView was paused. See MLWebViewPause.

MLResult.Code.InvalidParam if its unable to find the specified MLWebView handle.

MLResult.Code.WebViewResultZoomLimitReached if cannot zoom in any further.

MLResult.Code.UnspecifiedFailure if it failed to reset zoom due to an internal error.

MLResult.Code.Pending if the MLWebView handle is not ready to use.


MLResult.Code MLWebViewZoomOut

Zoom out one level.

public MLResult.Code MLWebViewZoomOut(
ulong handle
)

Parameters

TypeNameDescription
ulonghandleThe webview being accessed.

Returns: MLResult.Code.Ok if MLWebView zoomed out.

MLResult.Code.IllegalState if WebView was paused. See MLWebViewPause.

MLResult.Code.InvalidParam if its unable to find the specified MLWebView handle.

MLResult.Code.WebViewResultZoomLimitReached if cannot zoom out any further.

MLResult.Code.UnspecifiedFailure if it failed to reset zoom due to an internal error.

MLResult.Code.Pending if the MLWebView handle is not ready to use.


delegate bool OnBeforePopupCallback

The delegate for the webview before popup event.

public delegate bool OnBeforePopupCallback(
string url,
IntPtr userData
)

Parameters

TypeNameDescription
stringurl
IntPtruserData

delegate void OnBeforeResourceLoadCallback

The delegate for the before reasource loaded event.

public delegate void OnBeforeResourceLoadCallback(
string resourceUrl,
IntPtr userData
)

Parameters

TypeNameDescription
stringresourceUrlThe url of the resource about to be loaded.
IntPtruserDataUser defined data.

delegate bool OnCertificateErrorCallback

The delegate for the certificate error event.

public delegate bool OnCertificateErrorCallback(
int errorCode,
string url,
string errorMessage,
string details,
IntPtr userData
)

Parameters

TypeNameDescription
interrorCodeError code for ssl error.
stringurlThe url associated to the certificate error.
stringerrorMessageCertificate error short description.
stringdetailsCertificate error details.
IntPtruserDataUser defined data.

delegate void OnDestroyCallback

The delegate for the webview destroy event.

public delegate void OnDestroyCallback(
IntPtr userData
)

Parameters

TypeNameDescription
IntPtruserDataUser defined data.

delegate void OnKeyboardDismissCallback

The delegate for the keyboard dismiss event.

public delegate void OnKeyboardDismissCallback(
IntPtr userData
)

Parameters

TypeNameDescription
IntPtruserDataUser defined data.

delegate void OnLoadEndCallback

The delegate for the reasource loaded event.

public delegate void OnLoadEndCallback(
bool isMainFrame,
int httpStatusCode,
IntPtr userData
)

Parameters

TypeNameDescription
boolisMainFrameWhether this event was for the main frame.
inthttpStatusCodeThe standard http status code.
IntPtruserDataUser defined data.

delegate void OnLoadErrorCallback

The delegate for the reasource load error event.

public delegate void OnLoadErrorCallback(
bool isMainFrame,
int httpStatusCode,
string errorStr,
string failedUrl,
IntPtr userData
)

Parameters

TypeNameDescription
boolisMainFrameTrue if this event was for the main frame.
inthttpStatusCodeHttp status code for the URL load failure.
stringerrorStrThe stringified version of the error code.
stringfailedUrlThe url that caused the load error.
IntPtruserDataUser defined data.

delegate void OnPopupClosedCallback

The delegate for the webview popup closed event. 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.

public delegate void OnPopupClosedCallback(
ulong handle,
IntPtr userData
)

Parameters

TypeNameDescription
ulonghandle
IntPtruserData

delegate void OnPopupOpenedCallback

The delegate for the webview popup opened event.

public delegate void OnPopupOpenedCallback(
ulong popupID,
string url,
IntPtr userData
)

Parameters

TypeNameDescription
ulongpopupID
stringurl
IntPtruserData

delegate void OnServiceConnectedCallback

The delegate for the webview service connected event.

public delegate void OnServiceConnectedCallback(
IntPtr userData
)

Parameters

TypeNameDescription
IntPtruserData

delegate void OnServiceDisconnectedCallback

The delegate for the webview service disconnected event.

public delegate void OnServiceDisconnectedCallback(
IntPtr userData
)

Parameters

TypeNameDescription
IntPtruserData

delegate void OnServiceFailedCallback

The delegate for the webview service failed event.

public delegate void OnServiceFailedCallback(
MLResult result,
IntPtr userData
)

Parameters

TypeNameDescription
MLResultresultMagic Leap API return value.
IntPtruserData

delegate void OnShowKeyboardCallback

The delegate for the keyboard show event.

public delegate void OnShowKeyboardCallback(
int x,
int y,
int width,
int height,
TextInputFlags textInputFlags,
TextInputType textInputType,
IntPtr userData
)

Parameters

TypeNameDescription
intxHorizontal position of the input field.
intyVertical position of the input field.
intwidthWidth of the input field.
intheightHeight of the input field.
TextInputFlagstextInputFlagsOne or combination of TextInputFlags.
TextInputTypetextInputTypeOne of TextInputType.
IntPtruserDataUser defined data.