From 20b6cddc560568f70458b9605ed0b37477419021 Mon Sep 17 00:00:00 2001 From: Elisa Lupin-Jimenez Date: Wed, 23 Aug 2017 15:38:11 -0700 Subject: [PATCH] attempt to add active tablet button --- .../marketplace/blocks/blocksApp.js | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/unpublishedScripts/marketplace/blocks/blocksApp.js b/unpublishedScripts/marketplace/blocks/blocksApp.js index 2c20e13005..2979f7abae 100644 --- a/unpublishedScripts/marketplace/blocks/blocksApp.js +++ b/unpublishedScripts/marketplace/blocks/blocksApp.js @@ -16,6 +16,7 @@ var APP_NAME = "BLOCKS"; var APP_URL = "https://vr.google.com/objects/"; var APP_ICON = "https://hifi-content.s3.amazonaws.com/elisalj/blocks/blocks-i.svg"; + var APP_ICON_ACTIVE = "https://hifi-content.s3.amazonaws.com/elisalj/blocks/blocks-a.svg"; try { print("Current Interface version: " + Window.checkVersion()); @@ -26,7 +27,8 @@ var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); var button = tablet.addButton({ - icon: APP_ICON, + icon: APP_ICON, + activeIcon: APP_ICON_ACTIVE, text: APP_NAME }); @@ -35,6 +37,26 @@ } button.clicked.connect(onClicked); + function onScreenChanged(type, url) { + if (url !== null) { + tabletButton.editProperties({ isActive: true }); + + if (!shown) { + // hook up to the event bridge + tablet.webEventReceived.connect(onWebEventReceived); + } + shown = true; + } else { + tabletButton.editProperties({ isActive: false }); + + if (shown) { + // disconnect from the event bridge + tablet.webEventReceived.disconnect(onWebEventReceived); + } + shown = false; + } + } + function cleanup() { tablet.removeButton(button); }