self:set_message_handler

Client

Registers a handler function to receive messages posted from the webview


Syntax

local status = self:set_message_handler(
    handler
)

Parameters

TypeNameDescription
functionhandlerCallback function invoked when the webview posts a message via window.ipc.postMessage()

Returns

TypeNameDescription
boolstatustrue on successful execution, false otherwise

Examples

Register a message handler on a webview
local entity = core.webview.create()

entity:set_message_handler(function(message)
    core.engine.print("info", "Received message:", message)
end)

On this page