From 5b94c73303564a9d1857d3ef34830de0a6460eaf Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 11 Apr 2013 13:48:24 +0200 Subject: Morphic: Virtual Keyboard enhancements The input-element-as-virtual-keyboard-proxy mechanism now gets only activated on touchscreen devices. Whether the browser is a touchscreen device is determined whenever a touch event occurs. for iOS devices, autocapitalization is now turned off. --- morphic.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'morphic.js') diff --git a/morphic.js b/morphic.js index 4a9fa39..86f6f39 100644 --- a/morphic.js +++ b/morphic.js @@ -1033,7 +1033,7 @@ /*global window, HTMLCanvasElement, getMinimumFontHeight, FileReader, Audio, FileList, getBlurredShadowSupport*/ -var morphicVersion = '2013-April-10'; +var morphicVersion = '2013-April-11'; var modules = {}; // keep track of additional loaded modules var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug @@ -1051,6 +1051,7 @@ var standardSettings = { mouseScrollAmount: 40, useSliderForInput: false, useVirtualKeyboard: true, + isTouchDevice: false, // turned on by touch events, don't set rasterizeSVGs: false }; @@ -1068,6 +1069,7 @@ var touchScreenSettings = { mouseScrollAmount: 40, useSliderForInput: true, useVirtualKeyboard: true, + isTouchDevice: false, rasterizeSVGs: false }; @@ -9398,6 +9400,7 @@ HandMorph.prototype.processMouseDown = function (event) { HandMorph.prototype.processTouchStart = function (event) { var myself = this; + MorphicPreferences.isTouchDevice = true; clearInterval(this.touchHoldTimeout); if (event.touches.length === 1) { this.touchHoldTimeout = setInterval( // simulate mouseRightClick @@ -9416,6 +9419,7 @@ HandMorph.prototype.processTouchStart = function (event) { }; HandMorph.prototype.processTouchMove = function (event) { + MorphicPreferences.isTouchDevice = true; if (event.touches.length === 1) { var touch = event.touches[0]; this.processMouseMove(touch); @@ -9424,6 +9428,7 @@ HandMorph.prototype.processTouchMove = function (event) { }; HandMorph.prototype.processTouchEnd = function (event) { + MorphicPreferences.isTouchDevice = true; clearInterval(this.touchHoldTimeout); nop(event); this.processMouseUp({button: 0}); @@ -9921,7 +9926,8 @@ WorldMorph.prototype.initVirtualKeyboard = function () { document.body.removeChild(this.virtualKeyboard); this.virtualKeyboard = null; } - if (!MorphicPreferences.useVirtualKeyboard) { + if (!MorphicPreferences.isTouchDevice + || !MorphicPreferences.useVirtualKeyboard) { return; } this.virtualKeyboard = document.createElement("input"); @@ -9935,6 +9941,7 @@ WorldMorph.prototype.initVirtualKeyboard = function () { this.virtualKeyboard.style.left = "0px"; this.virtualKeyboard.style.width = "0px"; this.virtualKeyboard.style.height = "0px"; + this.virtualKeyboard.autocapitalize = "none"; // iOS specific document.body.appendChild(this.virtualKeyboard); this.virtualKeyboard.addEventListener( @@ -10528,7 +10535,8 @@ WorldMorph.prototype.edit = function (aStringOrTextMorph) { this.keyboardReceiver = this.cursor; this.initVirtualKeyboard(); - if (MorphicPreferences.useVirtualKeyboard) { + if (MorphicPreferences.isTouchDevice + && MorphicPreferences.useVirtualKeyboard) { this.virtualKeyboard.style.top = this.cursor.top() + pos.y + "px"; this.virtualKeyboard.style.left = this.cursor.left() + pos.x + "px"; this.virtualKeyboard.focus(); -- cgit v1.3.1