Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.6e

Application v 6.3a

  

 

Chapter Twenty-oneWebView Interface (continued)

JavaScriptSetMessageHandler Function

Overview

The JavaScriptSetMessageHandler function sets a Legato function as a message handler. This function will be executed whenever JavaScript within the WebView object posts a message.

Syntax/Parameters

Syntax

string = JavaScriptSetMessageHandler ( handle hWVO, string function );

Parameters

hWVO

A handle specifying a WebView Object.

function

A string specifying a Legato function name

Return Value

A string specifying the previous function name or an empty string on error. Note that this value value be empty under normal conditions. Use the IsError or GetLastError function to determine if an error occurred and the nature of the error.

Remarks

The specified Legato function will be called whenever JavaScript running within the WebView uses the window.chrome.webview.postMessage function. The callback should have the following definition

void handler (string json) {...}

The arguments passed from JavaScript are converted to a JSON string by the WebView. Certain objects may not translate well. The JSON string can be read as-is or using the Legato JSON parser. Because this function is a callback, the main Legato loop must be waiting for messages to be processed for the callback to occur. Developers should avoid calling additional JavaScript functions within the callback.

Related Functions

Platform Support

Go13, Go16, GoFiler Complete, GoFiler Corporate, GoFiler, GoFiler Lite, GoXBRL

Page revised 2025-10-20