OverlayWebWindow

Description

Supported Script Types: Interface Scripts • Client Entity Scripts • Avatar Scripts

A OverlayWebWindow displays an HTML window inside Interface.

Create using new OverlayWebWindow(...).

Properties

Name Type Summary
url string

The URL of the HTML displayed in the window. Read-only.

position Vec2

The position of the window, in pixels.

size Vec2

The size of the window interior, in pixels.

visible boolean

true if the window is visible, false if it isn't.

Constructor
new OverlayWebWindow( titleOrPropertiesopt, sourceopt, widthopt, heightopt )

Parameters

Name Type Attributes Default Value Description
titleOrProperties string | OverlayWindow.Properties <optional>
"WebWindow"

The window's title or initial property values.

source string <optional>
"about:blank"

The URL of the HTML to display. Not used unless the first parameter is the window title.

width number <optional>
0

The width of the window interior, in pixels. Not used unless the first parameter is the window title.

height number <optional>
0

The height of the window interior, in pixels. Not used unless the first parameter is the window title.

Methods

Name Return Value Summary
clearDebugWindow None

Deprecated: This method is deprecated and will be removed.

close None

Closes the window.

Note: The window also closes when the script ends.

emitScriptEvent None

Sends a message to the HTML page. To receive the message, the HTML page's script must connect to the EventBridge that is automatically provided for the script:

EventBridge.scriptEventReceived.connect(function(message) {
    ...
});
emitWebEvent None

Deprecated: This function is deprecated and will be removed.

getEventBridge object

Deprecated: This method is deprecated and will be removed.

getPosition Vec2

Gets the position of the window.

getSize Vec2

Gets the size of the window interior.

getURL string

Gets the URL of the HTML displayed.

hasClosed None

Deprecated: This method is deprecated and will be removed.

hasMoved None

Deprecated: This method is deprecated and will be removed.

initQml None

Deprecated: This method is deprecated and will be removed.

isVisible boolean

Gets whether the window is shown or hidden.

qmlToScript None

Deprecated: This method is deprecated and will be removed.

raise None

Raises the window to the top.

sendToQML None

Deprecated: This method is deprecated and will be removed.

setPosition None

Sets the position of the window, from a Vec2.

setPosition None

Sets the position of the window, from a pair of numbers.

setScriptURL None

Injects a script into the HTML page, replacing any currently injected script.

setSize None

Sets the size of the window interior, from a Vec2.

setSize None

Sets the size of the window interior, from a pair of numbers.

setTitle None

Sets the window title.

setURL None

Loads HTML into the window, replacing current window content.

setVisible None

Shows or hides the window.

Signals

Name Summary
closed

Triggered when the window is closed.

fromQML

Deprecated: This signal is deprecated and will be removed.

moved

Triggered when the window changes position.

positionChanged

Triggered when the window changes position.

resized

Triggered when the window changes size.

scriptEventReceived

Deprecated: This signal is deprecated and will be removed.

sizeChanged

Triggered when the window changes size.

urlChanged

Triggered when the window's URL changes.

visibleChanged

Triggered when the window is hidden or shown.

webEventReceived

Triggered when a message from the HTML page is received. The HTML page can send a message by calling:

EventBridge.emitWebEvent(message);

Method Details

(static) clearDebugWindow( )

Deprecated: This method is deprecated and will be removed.

(static) close( )

Closes the window.

Note: The window also closes when the script ends.

(static) emitScriptEvent( message )

Sends a message to the HTML page. To receive the message, the HTML page's script must connect to the EventBridge that is automatically provided for the script:

EventBridge.scriptEventReceived.connect(function(message) {
    ...
});

Parameters

Name Type Description
message string | object

The message to send to the embedded HTML page.

Examples

Send and receive messages with an HTML window.

// JavaScript file.

var overlayWebWindow = new OverlayWebWindow({
    title: "Overlay Web Window",
    source: Script.resolvePath("OverlayWebWindow.html"),
    width: 400,
    height: 300
});

overlayWebWindow.webEventReceived.connect(function (message) {
    print("Message received: " + message);
});

Script.setTimeout(function () {
    overlayWebWindow.emitScriptEvent("Hello world!");
}, 2000);
// HTML file, "OverlayWebWindow.html".

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
</head>
<body>
    <p id="hello">...</p>
</body>
<script>
    EventBridge.scriptEventReceived.connect(function (message) {
        document.getElementById("hello").innerHTML = message;
        EventBridge.emitWebEvent("Hello back!");
    });
</script>
</html>
(static) emitWebEvent( message )

Deprecated: This function is deprecated and will be removed.

Parameters

Name Type Description
message object | string

The message.

(static) getEventBridge( ) → {object}
Returns: Object.

Deprecated: This method is deprecated and will be removed.

(static) getPosition( ) → {Vec2}
Returns: The position of the window, in pixels.

Gets the position of the window.

(static) getSize( ) → {Vec2}
Returns: The size of the window interior, in pixels.

Gets the size of the window interior.

(static) getURL( ) → {string}
Returns: - The URL of the HTML page displayed.

Gets the URL of the HTML displayed.

(static) hasClosed( )

Deprecated: This method is deprecated and will be removed.

(static) hasMoved( position )

Deprecated: This method is deprecated and will be removed.

Parameters

Name Type Description
position Vec2

Position.

(static) initQml( properties )

Deprecated: This method is deprecated and will be removed.

Parameters

Name Type Description
properties OverlayWindow.Properties

Properties.

(static) isVisible( ) → {boolean}
Returns: code>true if the window is shown, false if it is hidden.

Gets whether the window is shown or hidden.

(static) qmlToScript( message )

Deprecated: This method is deprecated and will be removed.

Parameters

Name Type Description
message object

Message.

(static) raise( )

Raises the window to the top.

(static) sendToQML( message )

Deprecated: This method is deprecated and will be removed.

Parameters

Name Type Description
message string | object

Message.

(static) setPosition( position )

Sets the position of the window, from a Vec2.

Parameters

Name Type Description
position Vec2

The position of the window, in pixels.

(static) setPosition( x, y )

Sets the position of the window, from a pair of numbers.

Parameters

Name Type Description
x number

The x position of the window, in pixels.

y number

The y position of the window, in pixels.

(static) setScriptURL( url )

Injects a script into the HTML page, replacing any currently injected script.

Parameters

Name Type Description
url string

The URL of the script to inject.

(static) setSize( size )

Sets the size of the window interior, from a Vec2.

Parameters

Name Type Description
size Vec2

The size of the window interior, in pixels.

(static) setSize( width, height )

Sets the size of the window interior, from a pair of numbers.

Parameters

Name Type Description
width number

The width of the window interior, in pixels.

height number

The height of the window interior, in pixels.

(static) setTitle( title )

Sets the window title.

Parameters

Name Type Description
title string

The window title.

(static) setURL( url )

Loads HTML into the window, replacing current window content.

Parameters

Name Type Description
url string

The URL of the HTML to display.

(static) setVisible( visible )

Shows or hides the window.

Parameters

Name Type Description
visible boolean

code>true to show the window, false to hide it.

Signal Details

closed( )
Returns: Signal

Triggered when the window is closed.

fromQML( message )
Returns: Signal

Deprecated: This signal is deprecated and will be removed.

Parameters

Name Type Description
message object

Message.

moved( position )
Returns: Signal

Triggered when the window changes position.

Parameters

Name Type Description
position Vec2

The position of the window, in pixels.

positionChanged( )
Returns: Signal

Triggered when the window changes position.

resized( size )
Returns: Signal

Triggered when the window changes size.

Parameters

Name Type Description
size Size

The size of the window interior, in pixels.

scriptEventReceived( message )
Returns: Signal

Deprecated: This signal is deprecated and will be removed.

Parameters

Name Type Description
message object

The message.

sizeChanged( )
Returns: Signal

Triggered when the window changes size.

urlChanged( )
Returns: Signal

Triggered when the window's URL changes.

visibleChanged( )
Returns: Signal

Triggered when the window is hidden or shown.

webEventReceived( message )
Returns: Signal

Triggered when a message from the HTML page is received. The HTML page can send a message by calling:

EventBridge.emitWebEvent(message);

Parameters

Name Type Description
message string | object

The message received.