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.
pull/3/merge
jmoenig 2013-04-11 13:48:24 +02:00
rodzic cb41576e5a
commit 5b94c73303
2 zmienionych plików z 15 dodań i 3 usunięć

Wyświetl plik

@ -1612,3 +1612,7 @@ ______
------ ------
* Fixes for type casting and dragging dialogs by buttons, thanks, Nathan! * Fixes for type casting and dragging dialogs by buttons, thanks, Nathan!
* Fix for loading shared projects in different formats (cloud data and plain project data) * Fix for loading shared projects in different formats (cloud data and plain project data)
130411
------
* Morphic: virtual keyboard enhancements (see Morphic.js)

Wyświetl plik

@ -1033,7 +1033,7 @@
/*global window, HTMLCanvasElement, getMinimumFontHeight, FileReader, Audio, /*global window, HTMLCanvasElement, getMinimumFontHeight, FileReader, Audio,
FileList, getBlurredShadowSupport*/ FileList, getBlurredShadowSupport*/
var morphicVersion = '2013-April-10'; var morphicVersion = '2013-April-11';
var modules = {}; // keep track of additional loaded modules var modules = {}; // keep track of additional loaded modules
var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug
@ -1051,6 +1051,7 @@ var standardSettings = {
mouseScrollAmount: 40, mouseScrollAmount: 40,
useSliderForInput: false, useSliderForInput: false,
useVirtualKeyboard: true, useVirtualKeyboard: true,
isTouchDevice: false, // turned on by touch events, don't set
rasterizeSVGs: false rasterizeSVGs: false
}; };
@ -1068,6 +1069,7 @@ var touchScreenSettings = {
mouseScrollAmount: 40, mouseScrollAmount: 40,
useSliderForInput: true, useSliderForInput: true,
useVirtualKeyboard: true, useVirtualKeyboard: true,
isTouchDevice: false,
rasterizeSVGs: false rasterizeSVGs: false
}; };
@ -9398,6 +9400,7 @@ HandMorph.prototype.processMouseDown = function (event) {
HandMorph.prototype.processTouchStart = function (event) { HandMorph.prototype.processTouchStart = function (event) {
var myself = this; var myself = this;
MorphicPreferences.isTouchDevice = true;
clearInterval(this.touchHoldTimeout); clearInterval(this.touchHoldTimeout);
if (event.touches.length === 1) { if (event.touches.length === 1) {
this.touchHoldTimeout = setInterval( // simulate mouseRightClick this.touchHoldTimeout = setInterval( // simulate mouseRightClick
@ -9416,6 +9419,7 @@ HandMorph.prototype.processTouchStart = function (event) {
}; };
HandMorph.prototype.processTouchMove = function (event) { HandMorph.prototype.processTouchMove = function (event) {
MorphicPreferences.isTouchDevice = true;
if (event.touches.length === 1) { if (event.touches.length === 1) {
var touch = event.touches[0]; var touch = event.touches[0];
this.processMouseMove(touch); this.processMouseMove(touch);
@ -9424,6 +9428,7 @@ HandMorph.prototype.processTouchMove = function (event) {
}; };
HandMorph.prototype.processTouchEnd = function (event) { HandMorph.prototype.processTouchEnd = function (event) {
MorphicPreferences.isTouchDevice = true;
clearInterval(this.touchHoldTimeout); clearInterval(this.touchHoldTimeout);
nop(event); nop(event);
this.processMouseUp({button: 0}); this.processMouseUp({button: 0});
@ -9921,7 +9926,8 @@ WorldMorph.prototype.initVirtualKeyboard = function () {
document.body.removeChild(this.virtualKeyboard); document.body.removeChild(this.virtualKeyboard);
this.virtualKeyboard = null; this.virtualKeyboard = null;
} }
if (!MorphicPreferences.useVirtualKeyboard) { if (!MorphicPreferences.isTouchDevice
|| !MorphicPreferences.useVirtualKeyboard) {
return; return;
} }
this.virtualKeyboard = document.createElement("input"); this.virtualKeyboard = document.createElement("input");
@ -9935,6 +9941,7 @@ WorldMorph.prototype.initVirtualKeyboard = function () {
this.virtualKeyboard.style.left = "0px"; this.virtualKeyboard.style.left = "0px";
this.virtualKeyboard.style.width = "0px"; this.virtualKeyboard.style.width = "0px";
this.virtualKeyboard.style.height = "0px"; this.virtualKeyboard.style.height = "0px";
this.virtualKeyboard.autocapitalize = "none"; // iOS specific
document.body.appendChild(this.virtualKeyboard); document.body.appendChild(this.virtualKeyboard);
this.virtualKeyboard.addEventListener( this.virtualKeyboard.addEventListener(
@ -10528,7 +10535,8 @@ WorldMorph.prototype.edit = function (aStringOrTextMorph) {
this.keyboardReceiver = this.cursor; this.keyboardReceiver = this.cursor;
this.initVirtualKeyboard(); this.initVirtualKeyboard();
if (MorphicPreferences.useVirtualKeyboard) { if (MorphicPreferences.isTouchDevice
&& MorphicPreferences.useVirtualKeyboard) {
this.virtualKeyboard.style.top = this.cursor.top() + pos.y + "px"; this.virtualKeyboard.style.top = this.cursor.top() + pos.y + "px";
this.virtualKeyboard.style.left = this.cursor.left() + pos.x + "px"; this.virtualKeyboard.style.left = this.cursor.left() + pos.x + "px";
this.virtualKeyboard.focus(); this.virtualKeyboard.focus();