tabs to spaces

This commit is contained in:
Atlante45 2014-12-08 11:49:55 -08:00
parent b4f18f15d7
commit 716fca6ae7
2 changed files with 248 additions and 250 deletions

View file

@ -15,11 +15,11 @@ Script.include("libraries/toolBars.js");
var recordingFile = "recording.rec"; var recordingFile = "recording.rec";
function setPlayerOptions() { function setPlayerOptions() {
MyAvatar.setPlayFromCurrentLocation(true); MyAvatar.setPlayFromCurrentLocation(true);
MyAvatar.setPlayerUseDisplayName(false); MyAvatar.setPlayerUseDisplayName(false);
MyAvatar.setPlayerUseAttachments(false); MyAvatar.setPlayerUseAttachments(false);
MyAvatar.setPlayerUseHeadModel(false); MyAvatar.setPlayerUseHeadModel(false);
MyAvatar.setPlayerUseSkeletonModel(false); MyAvatar.setPlayerUseSkeletonModel(false);
} }
var windowDimensions = Controller.getViewportDimensions(); var windowDimensions = Controller.getViewportDimensions();
@ -47,118 +47,118 @@ setupTimer();
var watchStop = false; var watchStop = false;
function setupToolBar() { function setupToolBar() {
if (toolBar != null) { if (toolBar != null) {
print("Multiple calls to Recorder.js:setupToolBar()"); print("Multiple calls to Recorder.js:setupToolBar()");
return; return;
} }
Tool.IMAGE_HEIGHT /= 2; Tool.IMAGE_HEIGHT /= 2;
Tool.IMAGE_WIDTH /= 2; Tool.IMAGE_WIDTH /= 2;
toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL); toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL);
toolBar.setBack(COLOR_TOOL_BAR, ALPHA_OFF); toolBar.setBack(COLOR_TOOL_BAR, ALPHA_OFF);
recordIcon = toolBar.addTool({ recordIcon = toolBar.addTool({
imageURL: TOOL_ICON_URL + "recording-record.svg", imageURL: TOOL_ICON_URL + "recording-record.svg",
subImage: { x: 0, y: 0, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT }, subImage: { x: 0, y: 0, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT },
x: 0, y: 0, x: 0, y: 0,
width: Tool.IMAGE_WIDTH, width: Tool.IMAGE_WIDTH,
height: Tool.IMAGE_HEIGHT, height: Tool.IMAGE_HEIGHT,
alpha: MyAvatar.isPlaying() ? ALPHA_OFF : ALPHA_ON, alpha: MyAvatar.isPlaying() ? ALPHA_OFF : ALPHA_ON,
visible: true visible: true
}, true, !MyAvatar.isRecording()); }, true, !MyAvatar.isRecording());
var playLoopWidthFactor = 1.65; var playLoopWidthFactor = 1.65;
playIcon = toolBar.addTool({ playIcon = toolBar.addTool({
imageURL: TOOL_ICON_URL + "play-pause.svg", imageURL: TOOL_ICON_URL + "play-pause.svg",
width: playLoopWidthFactor * Tool.IMAGE_WIDTH, width: playLoopWidthFactor * Tool.IMAGE_WIDTH,
height: Tool.IMAGE_HEIGHT, height: Tool.IMAGE_HEIGHT,
alpha: (MyAvatar.isRecording() || MyAvatar.playerLength() === 0) ? ALPHA_OFF : ALPHA_ON, alpha: (MyAvatar.isRecording() || MyAvatar.playerLength() === 0) ? ALPHA_OFF : ALPHA_ON,
visible: true visible: true
}, false); }, false);
playLoopIcon = toolBar.addTool({ playLoopIcon = toolBar.addTool({
imageURL: TOOL_ICON_URL + "play-and-loop.svg", imageURL: TOOL_ICON_URL + "play-and-loop.svg",
subImage: { x: 0, y: 0, width: playLoopWidthFactor * Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT }, subImage: { x: 0, y: 0, width: playLoopWidthFactor * Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT },
width: playLoopWidthFactor * Tool.IMAGE_WIDTH, width: playLoopWidthFactor * Tool.IMAGE_WIDTH,
height: Tool.IMAGE_HEIGHT, height: Tool.IMAGE_HEIGHT,
alpha: (MyAvatar.isRecording() || MyAvatar.playerLength() === 0) ? ALPHA_OFF : ALPHA_ON, alpha: (MyAvatar.isRecording() || MyAvatar.playerLength() === 0) ? ALPHA_OFF : ALPHA_ON,
visible: true visible: true
}, false); }, false);
timerOffset = toolBar.width; timerOffset = toolBar.width;
spacing = toolBar.addSpacing(0); spacing = toolBar.addSpacing(0);
saveIcon = toolBar.addTool({ saveIcon = toolBar.addTool({
imageURL: TOOL_ICON_URL + "recording-save.svg", imageURL: TOOL_ICON_URL + "recording-save.svg",
width: Tool.IMAGE_WIDTH, width: Tool.IMAGE_WIDTH,
height: Tool.IMAGE_HEIGHT, height: Tool.IMAGE_HEIGHT,
alpha: (MyAvatar.isRecording() || MyAvatar.isPlaying() || MyAvatar.playerLength() === 0) ? ALPHA_OFF : ALPHA_ON, alpha: (MyAvatar.isRecording() || MyAvatar.isPlaying() || MyAvatar.playerLength() === 0) ? ALPHA_OFF : ALPHA_ON,
visible: true visible: true
}, false); }, false);
loadIcon = toolBar.addTool({ loadIcon = toolBar.addTool({
imageURL: TOOL_ICON_URL + "recording-upload.svg", imageURL: TOOL_ICON_URL + "recording-upload.svg",
width: Tool.IMAGE_WIDTH, width: Tool.IMAGE_WIDTH,
height: Tool.IMAGE_HEIGHT, height: Tool.IMAGE_HEIGHT,
alpha: (MyAvatar.isRecording() || MyAvatar.isPlaying()) ? ALPHA_OFF : ALPHA_ON, alpha: (MyAvatar.isRecording() || MyAvatar.isPlaying()) ? ALPHA_OFF : ALPHA_ON,
visible: true visible: true
}, false); }, false);
} }
function setupTimer() { function setupTimer() {
timer = Overlays.addOverlay("text", { timer = Overlays.addOverlay("text", {
font: { size: 15 }, font: { size: 15 },
text: (0.00).toFixed(3), text: (0.00).toFixed(3),
backgroundColor: COLOR_OFF, backgroundColor: COLOR_OFF,
x: 0, y: 0, x: 0, y: 0,
width: 0, width: 0,
height: 0, height: 0,
alpha: 1.0, alpha: 1.0,
backgroundAlpha: 1.0, backgroundAlpha: 1.0,
visible: true visible: true
}); });
slider = { x: 0, y: 0, slider = { x: 0, y: 0,
w: 200, h: 20, w: 200, h: 20,
pos: 0.0, // 0.0 <= pos <= 1.0 pos: 0.0, // 0.0 <= pos <= 1.0
}; };
slider.background = Overlays.addOverlay("text", { slider.background = Overlays.addOverlay("text", {
text: "", text: "",
backgroundColor: { red: 128, green: 128, blue: 128 }, backgroundColor: { red: 128, green: 128, blue: 128 },
x: slider.x, y: slider.y, x: slider.x, y: slider.y,
width: slider.w, width: slider.w,
height: slider.h, height: slider.h,
alpha: 1.0, alpha: 1.0,
backgroundAlpha: 1.0, backgroundAlpha: 1.0,
visible: true visible: true
}); });
slider.foreground = Overlays.addOverlay("text", { slider.foreground = Overlays.addOverlay("text", {
text: "", text: "",
backgroundColor: { red: 200, green: 200, blue: 200 }, backgroundColor: { red: 200, green: 200, blue: 200 },
x: slider.x, y: slider.y, x: slider.x, y: slider.y,
width: slider.pos * slider.w, width: slider.pos * slider.w,
height: slider.h, height: slider.h,
alpha: 1.0, alpha: 1.0,
backgroundAlpha: 1.0, backgroundAlpha: 1.0,
visible: true visible: true
}); });
} }
function updateTimer() { function updateTimer() {
var text = ""; var text = "";
if (MyAvatar.isRecording()) { if (MyAvatar.isRecording()) {
text = formatTime(MyAvatar.recorderElapsed()); text = formatTime(MyAvatar.recorderElapsed());
} else { } else {
text = formatTime(MyAvatar.playerElapsed()) + " / " + text = formatTime(MyAvatar.playerElapsed()) + " / " +
formatTime(MyAvatar.playerLength()); formatTime(MyAvatar.playerLength());
} }
Overlays.editOverlay(timer, { Overlays.editOverlay(timer, {
text: text text: text
}) })
toolBar.changeSpacing(text.length * 8 + ((MyAvatar.isRecording()) ? 15 : 0), spacing); toolBar.changeSpacing(text.length * 8 + ((MyAvatar.isRecording()) ? 15 : 0), spacing);
if (MyAvatar.isRecording()) { if (MyAvatar.isRecording()) {
@ -168,57 +168,56 @@ function updateTimer() {
} }
Overlays.editOverlay(slider.foreground, { Overlays.editOverlay(slider.foreground, {
width: slider.pos * slider.w width: slider.pos * slider.w
}); });
} }
function formatTime(time) { function formatTime(time) {
var MIN_PER_HOUR = 60; var MIN_PER_HOUR = 60;
var SEC_PER_MIN = 60; var SEC_PER_MIN = 60;
var MSEC_PER_SEC = 1000; var MSEC_PER_SEC = 1000;
var hours = Math.floor(time / (MSEC_PER_SEC * SEC_PER_MIN * MIN_PER_HOUR)); var hours = Math.floor(time / (MSEC_PER_SEC * SEC_PER_MIN * MIN_PER_HOUR));
time -= hours * (MSEC_PER_SEC * SEC_PER_MIN * MIN_PER_HOUR); time -= hours * (MSEC_PER_SEC * SEC_PER_MIN * MIN_PER_HOUR);
var minutes = Math.floor(time / (MSEC_PER_SEC * SEC_PER_MIN)); var minutes = Math.floor(time / (MSEC_PER_SEC * SEC_PER_MIN));
time -= minutes * (MSEC_PER_SEC * SEC_PER_MIN); time -= minutes * (MSEC_PER_SEC * SEC_PER_MIN);
var seconds = Math.floor(time / MSEC_PER_SEC); var seconds = Math.floor(time / MSEC_PER_SEC);
seconds = time / MSEC_PER_SEC; seconds = time / MSEC_PER_SEC;
var text = ""; var text = "";
text += (hours > 0) ? hours + ":" : text += (hours > 0) ? hours + ":" :
""; "";
text += (minutes > 0) ? ((minutes < 10 && text != "") ? "0" : "") + minutes + ":" : text += (minutes > 0) ? ((minutes < 10 && text != "") ? "0" : "") + minutes + ":" :
""; "";
text += ((seconds < 10 && text != "") ? "0" : "") + seconds.toFixed(3); text += ((seconds < 10 && text != "") ? "0" : "") + seconds.toFixed(3);
return text; return text;
} }
function moveUI() { function moveUI() {
var relative = { x: 70, y: 40 }; var relative = { x: 70, y: 40 };
toolBar.move(relative.x, toolBar.move(relative.x, windowDimensions.y - relative.y);
windowDimensions.y - relative.y); Overlays.editOverlay(timer, {
Overlays.editOverlay(timer, { x: relative.x + timerOffset - ToolBar.SPACING,
x: relative.x + timerOffset - ToolBar.SPACING, y: windowDimensions.y - relative.y - ToolBar.SPACING
y: windowDimensions.y - relative.y - ToolBar.SPACING });
});
slider.x = relative.x - ToolBar.SPACING; slider.x = relative.x - ToolBar.SPACING;
slider.y = windowDimensions.y - relative.y - slider.h - ToolBar.SPACING; slider.y = windowDimensions.y - relative.y - slider.h - ToolBar.SPACING;
Overlays.editOverlay(slider.background, { Overlays.editOverlay(slider.background, {
x: slider.x, x: slider.x,
y: slider.y, y: slider.y,
}); });
Overlays.editOverlay(slider.foreground, { Overlays.editOverlay(slider.foreground, {
x: slider.x, x: slider.x,
y: slider.y, y: slider.y,
}); });
} }
function mousePressEvent(event) { function mousePressEvent(event) {
clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y }); clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y });
if (recordIcon === toolBar.clicked(clickedOverlay, false) && !MyAvatar.isPlaying()) { if (recordIcon === toolBar.clicked(clickedOverlay, false) && !MyAvatar.isPlaying()) {
if (!MyAvatar.isRecording()) { if (!MyAvatar.isRecording()) {
@ -270,7 +269,7 @@ function mousePressEvent(event) {
if (!MyAvatar.isRecording() && !MyAvatar.isPlaying() && MyAvatar.playerLength() != 0) { if (!MyAvatar.isRecording() && !MyAvatar.isPlaying() && MyAvatar.playerLength() != 0) {
recordingFile = Window.save("Save recording to file", ".", "Recordings (*.hfr)"); recordingFile = Window.save("Save recording to file", ".", "Recordings (*.hfr)");
if (!(recordingFile === "null" || recordingFile === null || recordingFile === "")) { if (!(recordingFile === "null" || recordingFile === null || recordingFile === "")) {
MyAvatar.saveRecording(recordingFile); MyAvatar.saveRecording(recordingFile);
} }
} }
} else if (loadIcon === toolBar.clicked(clickedOverlay)) { } else if (loadIcon === toolBar.clicked(clickedOverlay)) {
@ -286,8 +285,8 @@ function mousePressEvent(event) {
} }
} }
} else if (MyAvatar.playerLength() > 0 && } else if (MyAvatar.playerLength() > 0 &&
slider.x < event.x && event.x < slider.x + slider.w && slider.x < event.x && event.x < slider.x + slider.w &&
slider.y < event.y && event.y < slider.y + slider.h) { slider.y < event.y && event.y < slider.y + slider.h) {
isSliding = true; isSliding = true;
slider.pos = (event.x - slider.x) / slider.w; slider.pos = (event.x - slider.x) / slider.w;
MyAvatar.setPlayerTime(slider.pos * MyAvatar.playerLength()); MyAvatar.setPlayerTime(slider.pos * MyAvatar.playerLength());
@ -311,14 +310,13 @@ function mouseReleaseEvent(event) {
} }
function update() { function update() {
var newDimensions = Controller.getViewportDimensions(); var newDimensions = Controller.getViewportDimensions();
if (windowDimensions.x != newDimensions.x || if (windowDimensions.x != newDimensions.x || windowDimensions.y != newDimensions.y) {
windowDimensions.y != newDimensions.y) { windowDimensions = newDimensions;
windowDimensions = newDimensions; moveUI();
moveUI(); }
}
updateTimer(); updateTimer();
if (watchStop && !MyAvatar.isPlaying()) { if (watchStop && !MyAvatar.isPlaying()) {
watchStop = false; watchStop = false;
@ -329,12 +327,12 @@ function update() {
} }
function scriptEnding() { function scriptEnding() {
if (MyAvatar.isRecording()) { if (MyAvatar.isRecording()) {
MyAvatar.stopRecording(); MyAvatar.stopRecording();
} }
if (MyAvatar.isPlaying()) { if (MyAvatar.isPlaying()) {
MyAvatar.stopPlaying(); MyAvatar.stopPlaying();
} }
toolBar.cleanup(); toolBar.cleanup();
Overlays.deleteOverlay(timer); Overlays.deleteOverlay(timer);
Overlays.deleteOverlay(slider.background); Overlays.deleteOverlay(slider.background);

View file

@ -32,168 +32,168 @@ var clickedButton = false;
var cursor = "|"; var cursor = "|";
// add more characters to the string if required // add more characters to the string if required
var keyString = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ var keyString = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
~!@#$%^&*()_+`1234567890-={}|[]\\:\";'<>?,./"; //permitted characters ~!@#$%^&*()_+`1234567890-={}|[]\\:\";'<>?,./"; //permitted characters
// This will create a text overlay that displays what you type // This will create a text overlay that displays what you type
var inputWindow = Overlays.addOverlay("text", { var inputWindow = Overlays.addOverlay("text", {
x: locationX, x: locationX,
y: locationY, y: locationY,
width: width, width: width,
height: height, height: height,
color: textColor, color: textColor,
backgroundColor: backColor, backgroundColor: backColor,
alpha: backgroundAlpha, alpha: backgroundAlpha,
backgroundAlpha: backgroundAlpha, backgroundAlpha: backgroundAlpha,
topMargin: topMargin, topMargin: topMargin,
leftMargin: leftMargin, leftMargin: leftMargin,
font: {size: fontSize}, font: {size: fontSize},
text: writing, text: writing,
visible: true visible: true
}); });
// This will create an image overlay of a button. // This will create an image overlay of a button.
var button1 = Overlays.addOverlay("image", { // green button var button1 = Overlays.addOverlay("image", { // green button
x: buttonLocationX, x: buttonLocationX,
y: locationY + 10, y: locationY + 10,
width: 40, width: 40,
height: 35, height: 35,
subImage: { x: 0, y: 0, width: 39, height: 35 }, subImage: { x: 0, y: 0, width: 39, height: 35 },
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/thumb.png", imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/thumb.png",
color: readyColor, color: readyColor,
visible: true visible: true
}); });
// This will create an image overlay of another button. // This will create an image overlay of another button.
var button2 = Overlays.addOverlay("image", { // red button var button2 = Overlays.addOverlay("image", { // red button
x: buttonLocationX, x: buttonLocationX,
y: locationY + 60, y: locationY + 60,
width: 40, width: 40,
height: 35, height: 35,
subImage: { x: 0, y: 0, width: 39, height: 35 }, subImage: { x: 0, y: 0, width: 39, height: 35 },
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/thumb.png", imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/thumb.png",
color: { red: 250, green: 2, blue: 2}, color: { red: 250, green: 2, blue: 2},
visible: true, visible: true,
}); });
// When our script shuts down, we should clean up all of our overlays // When our script shuts down, we should clean up all of our overlays
function scriptEnding() { function scriptEnding() {
Overlays.deleteOverlay(inputWindow); Overlays.deleteOverlay(inputWindow);
Overlays.deleteOverlay(button1); Overlays.deleteOverlay(button1);
Overlays.deleteOverlay(button2); Overlays.deleteOverlay(button2);
//Return control of keys to default on script ending //Return control of keys to default on script ending
for(var i=0; i<keyString.length; i++){ for(var i=0; i<keyString.length; i++){
var nextChar = keyString.charAt(i); var nextChar = keyString.charAt(i);
Controller.releaseKeyEvents({ text: nextChar}); Controller.releaseKeyEvents({ text: nextChar});
} }
Controller.releaseKeyEvents({"key": 0x5c}); // forward slash Controller.releaseKeyEvents({"key": 0x5c}); // forward slash
Controller.releaseKeyEvents({ text: "SHIFT"}); Controller.releaseKeyEvents({ text: "SHIFT"});
Controller.releaseKeyEvents({ text: "BACKSPACE"}); Controller.releaseKeyEvents({ text: "BACKSPACE"});
Controller.releaseKeyEvents({ text: "SPACE"}); Controller.releaseKeyEvents({ text: "SPACE"});
Controller.releaseKeyEvents({"key":16777220} ); //Enter Controller.releaseKeyEvents({"key":16777220} ); //Enter
Controller.releaseKeyEvents({"key":16777219} ); //Backspace Controller.releaseKeyEvents({"key":16777219} ); //Backspace
} }
Script.scriptEnding.connect(scriptEnding); Script.scriptEnding.connect(scriptEnding);
function resetForm(){ function resetForm(){
writing = ""; // Start with a blank string writing = ""; // Start with a blank string
Overlays.editOverlay(button1, {color: readyColor} ); Overlays.editOverlay(button1, {color: readyColor} );
Overlays.editOverlay(inputWindow, {backgroundColor: readyColor}); Overlays.editOverlay(inputWindow, {backgroundColor: readyColor});
clickedText = true; clickedText = true;
} }
function submitForm(){ function submitForm(){
print("form submitted"); print("form submitted");
writingOutput = writing; // writingOutput is the data output writingOutput = writing; // writingOutput is the data output
writing = writing + ".\nYour data has been stored.\n\nClick here to reset form or \n\n\nClick red button to close,"; writing = writing + ".\nYour data has been stored.\n\nClick here to reset form or \n\n\nClick red button to close,";
Overlays.editOverlay(button1, { color: clickedColor} ); Overlays.editOverlay(button1, { color: clickedColor} );
Overlays.editOverlay(inputWindow, {backgroundColor: clickedColor}); Overlays.editOverlay(inputWindow, {backgroundColor: clickedColor});
clickedText = false; clickedText = false;
clickedButton = true; clickedButton = true;
} }
// handle click detection // handle click detection
function mousePressEvent(event) { function mousePressEvent(event) {
var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y}); //identify which overlay was clicked var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y}); //identify which overlay was clicked
if (clickedOverlay == inputWindow) { // if the user clicked on the text window, prepare the overlay if (clickedOverlay == inputWindow) { // if the user clicked on the text window, prepare the overlay
if (clickedText == false){ // first time clicked? if (clickedText == false){ // first time clicked?
resetForm(); resetForm();
} }
} }
if (clickedOverlay == button1) { // if the user clicked on the green button if (clickedOverlay == button1) { // if the user clicked on the green button
if (clickedText == true){ // nothing happens unless the text window was clicked first if (clickedText == true){ // nothing happens unless the text window was clicked first
submitForm(); submitForm();
// clickedText == false; // clickedText == false;
} }
else { // if the form has been submitted already else { // if the form has been submitted already
resetForm(); resetForm();
} }
} }
if (clickedOverlay == button2) { // if the user clicked on the red button if (clickedOverlay == button2) { // if the user clicked on the red button
print ("script ending"); print ("script ending");
Script.stop(); Script.stop();
} }
} }
//handle key press detection //handle key press detection
function keyPressEvent(key) { function keyPressEvent(key) {
if (clickedText == true){ if (clickedText == true){
if (key.text == "SPACE") { //special conditions for space bar if (key.text == "SPACE") { //special conditions for space bar
writing = writing + " "; writing = writing + " ";
key.text =""; key.text ="";
} }
else if (key.text == "BACKSPACE") { // Backspace else if (key.text == "BACKSPACE") { // Backspace
var myString = writing; var myString = writing;
writing = myString.substr(0, myString.length-1); writing = myString.substr(0, myString.length-1);
key.text =""; key.text ="";
} }
if (key.text == "\r") { //special conditions for enter key if (key.text == "\r") { //special conditions for enter key
writing = writing + "\n"; writing = writing + "\n";
key.text =""; key.text ="";
} }
else if ( keyString.indexOf(key.text) == -1) { // prevent all other keys not in keyString else if ( keyString.indexOf(key.text) == -1) { // prevent all other keys not in keyString
key.text =""; key.text ="";
} }
// build the string // build the string
writing = writing + key.text; writing = writing + key.text;
} }
} }
var count = 0; var count = 0;
function updateWriting(deltaTime){ function updateWriting(deltaTime){
count++; count++;
// every half second or so, remove and replace the pipe to create a blinking cursor // every half second or so, remove and replace the pipe to create a blinking cursor
if (count % 30 == 0) { if (count % 30 == 0) {
if (cursor == "|") { if (cursor == "|") {
cursor=""; cursor="";
} else { } else {
cursor = "|"; cursor = "|";
} }
} }
// attempt at some overflow control of the text // attempt at some overflow control of the text
if ((writing.length % 53) == 0) { if ((writing.length % 53) == 0) {
writing = writing + "\n"; writing = writing + "\n";
} }
// add blinking cursor to window during typing // add blinking cursor to window during typing
var addCursor = writing + cursor; var addCursor = writing + cursor;
if (clickedText == true){ if (clickedText == true){
Overlays.editOverlay(inputWindow, { text: addCursor}); Overlays.editOverlay(inputWindow, { text: addCursor});
}else{ }else{
Overlays.editOverlay(inputWindow, { text: writing}); Overlays.editOverlay(inputWindow, { text: writing});
} }
} }
// test keystroke against keyString and capture permitted keys // test keystroke against keyString and capture permitted keys
for (var i=0; i<keyString.length; i++){ for (var i=0; i<keyString.length; i++){
var nextChar = keyString.charAt(i); var nextChar = keyString.charAt(i);
Controller.captureKeyEvents({ text: nextChar}); Controller.captureKeyEvents({ text: nextChar});
} }
// capture special keys // capture special keys
Controller.captureKeyEvents({ "key": 0x5c}); //forward slash key Controller.captureKeyEvents({ "key": 0x5c}); //forward slash key