property message

(r/o) string message;

Typ

Zugriff

This property returns the name of the message.
<hbox id="myBox" on:message="onMessage();"/>
<button label="send a message" on:command="sendMessage();"/>

// this function send a "hello" message to myBox
function sendMessage()
{
    var myBox = scene.getBoxById("myBox");
    var myDictionary = shell.serviceManager.basics.dictionary;
    if (myBox && myDictionary)
    {
        myBox.sendMessage("hello", myDictionary);
    }
}

// when myBox receive a message, print out the name of the message.
function onMessage()
{
    var eventObj = shell.currentEvent;
    if (eventObj)
    {
        var msg = eventObj.message;
        shell.print("the message is " + msg);
        // we should see the string "the message is hello" in Dbgview.

        // Get the payload.
        var dictionary = eventObj.paramsDictionary;
        if (dictionary)
        {
            // Do something.
        }
    }
}