// // textInputOverlayExample.js // Captures keystrokes and generates a string which is displayed as a text Overlay // demonstrates keystroke events, mouse click events and overlay buttons. // Created by Adrian McCarlie 7 October 2014 // // Copyright 2014 High Fidelity, Inc. // // // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // var locationX = 500; // on screen location X var locationY = 175; // on screen location Y var width = 600; //width of input window var height = 100; // height of input window var topMargin = 20; var leftMargin = 10; var textColor = { red: 228, green: 228, blue: 228}; // text color var backColor = { red: 170, green: 200, blue: 255}; // default background color var readyColor = { red: 2, green: 255, blue: 2}; // green background and button var clickedColor = { red: 255, green: 220, blue: 20}; //amber background and button var backgroundAlpha = 0.6; var fontSize = 12; var writing ="Click here and type input, then click green button to submit.\n \n \n \n \n \n \n \n Click red button to close,"; var buttonLocationX = locationX - 50; // buttons locked relative to input window var clickedText = false; var clickedButton = false; var cursor = "|"; // add more characters to the string if required var keyString = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ ~!@#$%^&*()_+`1234567890-={}|[]\\:\";'<>?,./"; //permitted characters // This will create a text overlay that displays what you type var inputWindow = Overlays.addOverlay("text", { x: locationX, y: locationY, width: width, height: height, color: textColor, backgroundColor: backColor, alpha: backgroundAlpha, backgroundAlpha: backgroundAlpha, topMargin: topMargin, leftMargin: leftMargin, font: {size: fontSize}, text: writing, visible: true }); // This will create an image overlay of a button. var button1 = Overlays.addOverlay("image", { // green button x: buttonLocationX, y: locationY + 10, width: 40, height: 35, subImage: { x: 0, y: 0, width: 39, height: 35 }, imageURL: "https://public.highfidelity.io/images/thumb.png", color: readyColor, visible: true }); // This will create an image overlay of another button. var button2 = Overlays.addOverlay("image", { // red button x: buttonLocationX, y: locationY + 60, width: 40, height: 35, subImage: { x: 0, y: 0, width: 39, height: 35 }, imageURL: "https://public.highfidelity.io/images/thumb.png", color: { red: 250, green: 2, blue: 2}, visible: true, }); // When our script shuts down, we should clean up all of our overlays function scriptEnding() { Overlays.deleteOverlay(inputWindow); Overlays.deleteOverlay(button1); Overlays.deleteOverlay(button2); //Return control of keys to default on script ending for(var i=0; i