mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 13:40:02 +02:00
hide cursor
This commit is contained in:
parent
0f6ad4eba0
commit
38d49854cb
2 changed files with 32 additions and 13 deletions
|
@ -20,7 +20,7 @@ Script.include("../../libraries/globals.js");
|
||||||
Script.include("../../libraries/virtualKeyboard.js");
|
Script.include("../../libraries/virtualKeyboard.js");
|
||||||
|
|
||||||
var windowDimensions = Controller.getViewportDimensions();
|
var windowDimensions = Controller.getViewportDimensions();
|
||||||
var cursor = null;
|
var cursor = new Cursor({visible: false});
|
||||||
var keyboard = new Keyboard({visible: false});
|
var keyboard = new Keyboard({visible: false});
|
||||||
var textFontSize = 9;
|
var textFontSize = 9;
|
||||||
var text = null;
|
var text = null;
|
||||||
|
@ -91,7 +91,7 @@ keyboard.onFullyLoaded = function() {
|
||||||
});
|
});
|
||||||
updateTextOverlay();
|
updateTextOverlay();
|
||||||
// the cursor is being loaded after the keyboard, else it will be on the background of the keyboard
|
// the cursor is being loaded after the keyboard, else it will be on the background of the keyboard
|
||||||
cursor = new Cursor();
|
cursor.updateVisibility(keyboard.visible);
|
||||||
cursor.onUpdate = function(position) {
|
cursor.onUpdate = function(position) {
|
||||||
keyboard.setFocusPosition(position.x, position.y);
|
keyboard.setFocusPosition(position.x, position.y);
|
||||||
};
|
};
|
||||||
|
@ -102,6 +102,9 @@ function keyPressEvent(event) {
|
||||||
keyboard.pressFocussedKey();
|
keyboard.pressFocussedKey();
|
||||||
} else if (event.key === ENTER_CHARCODE || event.key === RETURN_CHARCODE) {
|
} else if (event.key === ENTER_CHARCODE || event.key === RETURN_CHARCODE) {
|
||||||
keyboard.toggle();
|
keyboard.toggle();
|
||||||
|
if (cursor !== undefined) {
|
||||||
|
cursor.updateVisibility(keyboard.visible);
|
||||||
|
}
|
||||||
Overlays.editOverlay(text, {visible: keyboard.visible});
|
Overlays.editOverlay(text, {visible: keyboard.visible});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,7 +184,7 @@ Keyboard = (function(params) {
|
||||||
this.focussed_key = -1;
|
this.focussed_key = -1;
|
||||||
this.scale = (windowDimensions.x / KEYBOARD_WIDTH) * KEYBOARD_SCALE_MULTIPLIER;
|
this.scale = (windowDimensions.x / KEYBOARD_WIDTH) * KEYBOARD_SCALE_MULTIPLIER;
|
||||||
this.shift = false;
|
this.shift = false;
|
||||||
this.visible = params.visible != undefined ? params.visible :true;
|
this.visible = params.visible != undefined ? params.visible : true;
|
||||||
this.width = function() {
|
this.width = function() {
|
||||||
return KEYBOARD_WIDTH * tthis.scale;
|
return KEYBOARD_WIDTH * tthis.scale;
|
||||||
};
|
};
|
||||||
|
@ -320,21 +320,19 @@ Keyboard = (function(params) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.show = function() {
|
this.show = function() {
|
||||||
tthis.visible = true;
|
tthis.updateVisibility(true);
|
||||||
tthis.updateVisibility();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.hide = function() {
|
this.hide = function() {
|
||||||
tthis.visible = false;
|
tthis.updateVisibility(false);
|
||||||
tthis.updateVisibility();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.toggle = function() {
|
this.toggle = function() {
|
||||||
tthis.visible = !tthis.visible;
|
tthis.updateVisibility(!tthis.visible);
|
||||||
tthis.updateVisibility();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.updateVisibility = function() {
|
this.updateVisibility = function(visible) {
|
||||||
|
tthis.visible = visible;
|
||||||
Overlays.editOverlay(tthis.background, { visible: tthis.visible });
|
Overlays.editOverlay(tthis.background, { visible: tthis.visible });
|
||||||
for (var i = 0; i < this.keys.length; i++) {
|
for (var i = 0; i < this.keys.length; i++) {
|
||||||
this.keys[i].updateVisibility();
|
this.keys[i].updateVisibility();
|
||||||
|
@ -454,8 +452,12 @@ Keyboard = (function(params) {
|
||||||
this.keyboardTextureLoaded_timer = Script.setInterval(this.keyboardTextureLoaded, 250);
|
this.keyboardTextureLoaded_timer = Script.setInterval(this.keyboardTextureLoaded, 250);
|
||||||
});
|
});
|
||||||
|
|
||||||
Cursor = (function() {
|
Cursor = (function(params) {
|
||||||
|
if (params === undefined) {
|
||||||
|
params = {};
|
||||||
|
}
|
||||||
var tthis = this;
|
var tthis = this;
|
||||||
|
this.visible = params.visible != undefined ? params.visible : true;
|
||||||
this.x = windowDimensions.x / 2;
|
this.x = windowDimensions.x / 2;
|
||||||
this.y = windowDimensions.y / 2;
|
this.y = windowDimensions.y / 2;
|
||||||
this.overlay = Overlays.addOverlay("image", {
|
this.overlay = Overlays.addOverlay("image", {
|
||||||
|
@ -464,7 +466,8 @@ Cursor = (function() {
|
||||||
width: CURSOR_WIDTH,
|
width: CURSOR_WIDTH,
|
||||||
height: CURSOR_HEIGHT,
|
height: CURSOR_HEIGHT,
|
||||||
imageURL: CURSOR_URL,
|
imageURL: CURSOR_URL,
|
||||||
alpha: 1
|
alpha: 1,
|
||||||
|
visible: this.visible
|
||||||
});
|
});
|
||||||
this.remove = function() {
|
this.remove = function() {
|
||||||
Overlays.deleteOverlay(this.overlay);
|
Overlays.deleteOverlay(this.overlay);
|
||||||
|
@ -478,6 +481,19 @@ Cursor = (function() {
|
||||||
this.getY = function() {
|
this.getY = function() {
|
||||||
return tthis.y;
|
return tthis.y;
|
||||||
};
|
};
|
||||||
|
this.show = function() {
|
||||||
|
tthis.updateVisibility(true);
|
||||||
|
};
|
||||||
|
this.hide = function() {
|
||||||
|
tthis.updateVisibility(false);
|
||||||
|
};
|
||||||
|
this.toggle = function() {
|
||||||
|
tthis.updateVisibility(!tthis.visible);
|
||||||
|
};
|
||||||
|
this.updateVisibility = function(visible) {
|
||||||
|
tthis.visible = visible;
|
||||||
|
Overlays.editOverlay(this.overlay, { visible: tthis.visible });
|
||||||
|
};
|
||||||
this.onUpdate = null;
|
this.onUpdate = null;
|
||||||
this.update = function() {
|
this.update = function() {
|
||||||
var newWindowDimensions = Controller.getViewportDimensions();
|
var newWindowDimensions = Controller.getViewportDimensions();
|
||||||
|
|
Loading…
Reference in a new issue