Event Listeners
Introduction
Name
Description
π API Explanation and Example
onMessage
Name
Type
Description

Last updated
Was this helpful?

Last updated
Was this helpful?
Was this helpful?
// Activates function when a player enters
App.onJoinPlayer.Add(function (player) {
player.tag = {
widget: null,
};
player.tag.widget = player.showWidget("sample.html.html", "top", 600, 500);
player.tag.widget.onMessage.Add(function (player, msg) {
// Closes the widget when the 'type: close' message is sent from the widget to the App
if (msg.type == "close") {
player.showCenterLabel("Widget has been closed.");
player.tag.widget.destroy();
player.tag.widget = null;
}
});
});<i onclick="closeWidget()" class="fa-solid fa-xmark"></i>
<script type="text/javascript">
// Calls the function when x button is pressed
function closeWidget() {
// Sends message to App
window.parent.postMessage(
{
type: "close",
},
"*"
);
}
</script>