event handling - can now load models

This commit is contained in:
Faye Li 2017-02-15 16:19:56 -08:00
parent 2c77580ee9
commit 19bff20ebf
2 changed files with 32 additions and 42 deletions

View file

@ -93,13 +93,19 @@
elPictureButton.addEventListener('click', function() {
emit("onClickPictureButton", {value: "faye"});
});
});
}
$(document).ready(function() {
// Send a ready event to hifi
emit("ready", null);
// Send an event to hifi to trigger snapshot
$("#picture-button").click(function() {
emit("onClickPictureButton", null);
});
// Send an event to hifi for loading the given model URL
$("#reload-model-button").click(function() {
emit("onClickReloadModelButton", {value: $("#model-url").val()});
});
});
</script>
</body>

View file

@ -34,7 +34,29 @@
event = JSON.parse(event);
}
if (event.app === "photobooth") {
if (event.type === "onClickPictureButton") {
print("clicked picture button");
// // hide HUD tool bar
// toolbar.writeProperty("visible", false);
// // hide Overlays (such as Running Scripts or other Dialog UI)
// Menu.setIsOptionChecked("Overlays", false);
// // hide mouse cursor
// Reticle.visible = false;
// // giving a delay here before snapshotting so that there is time to hide toolbar and other UIs
// // void WindowScriptingInterface::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio)
// Script.setTimeout(function () {
// Window.takeSnapshot(false, false, 1.91);
// // show hidden items after snapshot is taken
// toolbar.writeProperty("visible", true);
// Menu.setIsOptionChecked("Overlays", true);
// // unknown issue: somehow we don't need to reset cursor to visible in script and the mouse still returns after snapshot
// // Reticle.visible = true;
// }, SNAPSHOT_DELAY);
} else if (event.type === "onClickReloadModelButton"){
print("clicked reload model button " + event.data.value);
PhotoBooth.changeModel(event.data.value);
}
}
}
@ -131,12 +153,6 @@
var main = function () {
var photoboothWindowListener = {};
photoboothWindowListener.onLoad = function (event) {
print("loaded" + event.value);
if (!event.hasOwnProperty("value")){
return;
}
};
photoboothWindowListener.onSelectCamera = function (event) {
print("selected camera " + event.value);
@ -151,38 +167,6 @@
Camera.setCameraEntity(cameraID);
}
};
photoboothWindowListener.onSelectLightingPreset = function (event) {
print("selected lighting preset" + event.value);
if (!event.hasOwnProperty("value")){
return;
}
};
photoboothWindowListener.onClickPictureButton = function (event) {
print("clicked picture button");
// hide HUD tool bar
toolbar.writeProperty("visible", false);
// hide Overlays (such as Running Scripts or other Dialog UI)
Menu.setIsOptionChecked("Overlays", false);
// hide mouse cursor
Reticle.visible = false;
// giving a delay here before snapshotting so that there is time to hide toolbar and other UIs
// void WindowScriptingInterface::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio)
Script.setTimeout(function () {
Window.takeSnapshot(false, false, 1.91);
// show hidden items after snapshot is taken
toolbar.writeProperty("visible", true);
Menu.setIsOptionChecked("Overlays", true);
// unknown issue: somehow we don't need to reset cursor to visible in script and the mouse still returns after snapshot
// Reticle.visible = true;
}, SNAPSHOT_DELAY);
};
photoboothWindowListener.onClickReloadModelButton = function (event) {
print("clicked reload model button " + event.value);
PhotoBooth.changeModel(event.value);
};
};
main();