From 8df6cd58c67bb649f7140872b32f100a2a18f471 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 21 Mar 2018 15:50:22 +1300 Subject: [PATCH] Document Overlays.getOverlayObject's use for web3d event bridge --- interface/src/ui/overlays/Overlays.h | 39 ++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/interface/src/ui/overlays/Overlays.h b/interface/src/ui/overlays/Overlays.h index 544aea75e0..a47a85624c 100644 --- a/interface/src/ui/overlays/Overlays.h +++ b/interface/src/ui/overlays/Overlays.h @@ -236,11 +236,46 @@ public slots: QString getOverlayType(OverlayID overlayId); /**jsdoc - * Get the overlay script object. + * Get the overlay script object. In particular, this is useful for accessing the event bridge for a web3d + * overlay. * @function Overlays.getOverlayObject - * @deprecated This function is deprecated and will soon be removed. * @param {Uuid} overlayID - The ID of the overlay to get the script object of. * @returns {object} The script object for the overlay if found. + * @example Receive "hello" messages from a web3d overlay. + * // HTML file: name "web3d.html". + * + * + * + * HELLO + * + * + *

HELLO

+ * + * + * + * + * // Script file. + * var web3dOverlay = Overlays.addOverlay("web3d", { + * position: Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, {x: 0, y: 0.5, z: -3 })), + * rotation: MyAvatar.orientation, + * url: Script.resolvePath("web3d.html"), + * alpha: 1.0 + * }); + * + * function onWebEventReceived(event) { + * print("onWebEventReceived() : " + JSON.stringify(event)); + * } + * + * overlayObject = Overlays.getOverlayObject(web3dOverlay); + * overlayObject.webEventReceived.connect(onWebEventReceived); + * + * Script.scriptEnding.connect(function () { + * Overlays.deleteOverlay(web3dOverlay); + * }); */ QObject* getOverlayObject(OverlayID id);