Desktop

Description

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

The Desktop API provides the dimensions of the computer screen, sets the opacity of the HUD surface, and enables QML and HTML windows to be shown inside or outside of Interface.

Properties

Name Type Summary
width number

The width of the computer screen including task bar and system menu, in pixels. Read-only.

height number

The height of the computer screen including task bar and system menu, in pixels. Read-only.

ALWAYS_ON_TOP InteractiveWindow.Flags

A flag value that makes an InteractiveWindow always display on top. Read-only.

CLOSE_BUTTON_HIDES InteractiveWindow.Flags

A flag value that makes an InteractiveWindow hide instead of closing when the user clicks the "close" button. Read-only.

PresentationMode InteractiveWindow.PresentationModes

The possible display options for an InteractiveWindow: display inside Interface or in a separate desktop window. Read-only.

DockArea InteractiveWindow.DockAreas

The possible docking locations of an InteractiveWindow: top, bottom, left, or right of the Interface window. Read-only.

RelativePositionAnchor InteractiveWindow.RelativePositionAnchors

The possible relative position anchors for an InteractiveWindow: none, top left, top right, bottom right, or bottom left of the Interface window. Read-only.

Methods

Name Return Value Summary
createWindow InteractiveWindow

Creates a new window that can be displayed either within Interface or as a separate desktop window.

setHUDAlpha None

Sets the opacity of the HUD surface.

show None

Opens a QML window within Interface: in the Interface window in desktop mode or on the HUD surface in HMD mode. If a window of the specified name already exists, it is shown, otherwise a new window is created from the QML.

Method Details

(static) createWindow( url, propertiesopt ) → {InteractiveWindow}
Returns: A new window object.

Creates a new window that can be displayed either within Interface or as a separate desktop window.

Parameters

Name Type Attributes Description
url string

The QML file that specifies the window content. The QML file can use a WebView control (defined by "WebView.qml" included in the Interface install) to embed an HTML web page (complete with EventBridge object).

properties InteractiveWindow.WindowProperties <optional>

Initial window properties.

Example

Open a dialog in its own window separate from Interface.

var nativeWindow = Desktop.createWindow(Script.resourcesPath() + 'qml/OverlayWindowTest.qml', {
    title: "Native Window",
    presentationMode: Desktop.PresentationMode.NATIVE,
    size: { x: 500, y: 400 }
});

Script.scriptEnding.connect(function () {
    nativeWindow.close();
});
     
(static) setHUDAlpha( alpha )

Sets the opacity of the HUD surface.

Parameters

Name Type Description
alpha number

The opacity, 0.0 – 1.0.

(static) show( url, name )

Opens a QML window within Interface: in the Interface window in desktop mode or on the HUD surface in HMD mode. If a window of the specified name already exists, it is shown, otherwise a new window is created from the QML.

Parameters

Name Type Description
url string

The QML file that specifies the window content.

name string

A unique name for the window.

Example

Open the general settings dialog.

Desktop.show("hifi/dialogs/GeneralPreferencesDialog.qml", "GeneralPreferencesDialog");