fixes for the virtualKeyboardTextEntityExample

This commit is contained in:
Thijs Wenker 2015-02-11 22:57:59 +01:00
parent 525fe7881e
commit 2c52c9c3c0

View file

@ -27,7 +27,7 @@ const TEXT_MARGIN_RIGHT = 0.17;
const TEXT_MARGIN_BOTTOM = 0.17;
var windowDimensions = Controller.getViewportDimensions();
var cursor = null;
var cursor = new Cursor();
var keyboard = new Keyboard();
var textFontSize = 9;
var text = null;
@ -84,7 +84,9 @@ keyboard.onKeyRelease = function(event) {
maxLineWidth = usernameWidth;
} else {
var spaceableWidth = maxLineWidth - usernameWidth;
var spaceWidth = Overlays.textSize(textSizeMeasureOverlay, " ").width;
//TODO: WORKAROUND WARNING BELOW Fix this when spaces are not trimmed out of the textsize calculation anymore
var spaceWidth = Overlays.textSize(textSizeMeasureOverlay, "| |").width
- Overlays.textSize(textSizeMeasureOverlay, "||").width;
var numberOfSpaces = Math.floor(spaceableWidth / spaceWidth);
for (var i = 0; i < numberOfSpaces; i++) {
usernameLine = " " + usernameLine;
@ -127,7 +129,7 @@ keyboard.onFullyLoaded = function() {
});
updateTextOverlay();
// the cursor is being loaded after the keyboard, else it will be on the background of the keyboard
cursor = new Cursor();
cursor.initialize();
cursor.onUpdate = function(position) {
keyboard.setFocusPosition(position.x, position.y);
};