ICoreWebView2WebMessageReceivedEventArgs

Trait ICoreWebView2WebMessageReceivedEventArgs 

Source
pub trait ICoreWebView2WebMessageReceivedEventArgs: IUnknown {
    // Required methods
    unsafe fn get_source(&self, source: *mut LPWSTR) -> HRESULT;
    unsafe fn get_web_message_as_json(
        &self,
        web_message_as_json: *mut LPWSTR,
    ) -> HRESULT;
    unsafe fn try_get_web_message_as_string(
        &self,
        web_message_as_string: *mut LPWSTR,
    ) -> HRESULT;
}
Expand description

Event args for the WebMessageReceived event.

Required Methods§

Source

unsafe fn get_source(&self, source: *mut LPWSTR) -> HRESULT

The URI of the document that sent this web message.

Source

unsafe fn get_web_message_as_json( &self, web_message_as_json: *mut LPWSTR, ) -> HRESULT

The message posted from the WebView content to the host converted to a JSON string. Run this operation to communicate using JavaScript objects.

For example, the following postMessage runs result in the following WebMessageAsJson values.

postMessage({'a': 'b'})      L"{\"a\": \"b\"}"
postMessage(1.2)             L"1.2"
postMessage('example')       L"\"example\""
Source

unsafe fn try_get_web_message_as_string( &self, web_message_as_string: *mut LPWSTR, ) -> HRESULT

If the message posted from the WebView content to the host is a string type, this method returns the value of that string. If the message posted is some other kind of JavaScript type this method fails with the following error.

E_INVALIDARG

Run this operation to communicate using simple strings.

For example, the following postMessage runs result in the following WebMessageAsString values.

postMessage({'a': 'b'})      E_INVALIDARG
postMessage(1.2)             E_INVALIDARG
postMessage('example')       L"example"

Trait Implementations§

Source§

impl ComInterface for dyn ICoreWebView2WebMessageReceivedEventArgs

Source§

const IID: IID = IID_ICORE_WEB_VIEW2_WEB_MESSAGE_RECEIVED_EVENT_ARGS

The associated id for this interface
Source§

type VTable = ICoreWebView2WebMessageReceivedEventArgsVTable

A COM compatible V-Table
Source§

type Super = dyn IUnknown

The interface that this interface inherits from
Source§

fn is_iid_in_inheritance_chain(riid: &GUID) -> bool

Check whether a given IID is in the inheritance hierarchy of this interface
Source§

impl<C: ICoreWebView2WebMessageReceivedEventArgs> ProductionComInterface<C> for dyn ICoreWebView2WebMessageReceivedEventArgs

Source§

fn vtable<O: Offset>() -> Self::VTable

Get the vtable for a particular COM interface

Implementations on Foreign Types§

Source§

impl<T: ICoreWebView2WebMessageReceivedEventArgs + ComInterface + ?Sized> ICoreWebView2WebMessageReceivedEventArgs for ComPtr<T>

Source§

unsafe fn get_source(&self, source: *mut LPWSTR) -> HRESULT

Source§

unsafe fn get_web_message_as_json( &self, web_message_as_json: *mut LPWSTR, ) -> HRESULT

Source§

unsafe fn try_get_web_message_as_string( &self, web_message_as_string: *mut LPWSTR, ) -> HRESULT

Source§

impl<T: ICoreWebView2WebMessageReceivedEventArgs + ComInterface + ?Sized> ICoreWebView2WebMessageReceivedEventArgs for ComRc<T>

Source§

unsafe fn get_source(&self, source: *mut LPWSTR) -> HRESULT

Source§

unsafe fn get_web_message_as_json( &self, web_message_as_json: *mut LPWSTR, ) -> HRESULT

Source§

unsafe fn try_get_web_message_as_string( &self, web_message_as_string: *mut LPWSTR, ) -> HRESULT

Implementors§