From 69e9326d4f9fc7478fe1543f0f085c2cecbff5b1 Mon Sep 17 00:00:00 2001 From: Adam Carruthers Date: Thu, 4 Dec 2014 17:06:33 -0500 Subject: [PATCH 1/2] fix #500 - requests keyboard focus when canvas is clicked The canvas click listener will now check if keyboard-command-area has focus, and if it does not, it will request it. --- src/viewer.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/viewer.js b/src/viewer.js index 39ed6294..b0ac0e47 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -2265,6 +2265,13 @@ function onBlur(){ function onCanvasClick( event ) { var gestureSettings; + var haveKeyboardFocus = document.activeElement == this.keyboardCommandArea; + + // If we don't have keyboard focus, request it. + if ( !haveKeyboardFocus ) { + this.keyboardCommandArea.focus(); + } + if ( !event.preventDefaultAction && this.viewport && event.quick ) { gestureSettings = this.gestureSettingsByDeviceType( event.pointerType ); if ( gestureSettings.clickToZoom ) { From 6e49f802487e0f45aecc25b9d45ecd9e296da47a Mon Sep 17 00:00:00 2001 From: Adam Carruthers Date: Mon, 22 Dec 2014 20:29:44 -0700 Subject: [PATCH 2/2] Prevent mobile keyboard from opening Adds readonly property to .keyboard-command-area to prevent input, but allow keys to be captured. --- src/viewer.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/viewer.js b/src/viewer.js index b0ac0e47..1ff4e1c9 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -300,6 +300,8 @@ $.Viewer = function( options ) { style.left = "0px"; style.resize = "none"; }( this.keyboardCommandArea.style )); + // Set read-only - hides keyboard on mobile devices, still allows input. + this.keyboardCommandArea.readOnly = true; this.container.insertBefore( this.canvas, this.container.firstChild ); this.container.insertBefore( this.keyboardCommandArea, this.container.firstChild );