From b0639be8bdf59eac377b0d939c5ed9c08a92fd1d Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Tue, 11 Jul 2017 15:23:50 -0700 Subject: [PATCH] Use function pointers correctly --- scripts/system/spectatorCamera.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/system/spectatorCamera.js b/scripts/system/spectatorCamera.js index a9069a66a6..94e3dbde02 100644 --- a/scripts/system/spectatorCamera.js +++ b/scripts/system/spectatorCamera.js @@ -190,9 +190,7 @@ tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); addOrRemoveButton(false, HMD.active); tablet.screenChanged.connect(onTabletScreenChanged); - Window.domainChanged.connect(function () { - spectatorCameraOff(true); - }); + Window.domainChanged.connect(onDomainChanged); Window.geometryChanged.connect(resizeViewFinderOverlay); Controller.keyPressEvent.connect(keyPressEvent); HMD.displayModeChanged.connect(onHMDChanged); @@ -483,9 +481,7 @@ // -shutdown() will be called when the script ends (i.e. is stopped). function shutdown() { spectatorCameraOff(); - Window.domainChanged.disconnect(function () { - spectatorCameraOff(true); - }); + Window.domainChanged.disconnect(onDomainChanged); Window.geometryChanged.disconnect(resizeViewFinderOverlay); addOrRemoveButton(true, HMD.active); if (tablet) { @@ -501,6 +497,14 @@ } } + // Function Name: onDomainChanged() + // + // Description: + // -A small utility function used when the Window.domainChanged() signal is fired. + function onDomainChanged() { + spectatorCameraOff(true); + } + // These functions will be called when the script is loaded. startup(); Script.scriptEnding.connect(shutdown);