Merge pull request #537 from bitjutsu/bug-500-keyboard-nav

fix #500 - requests keyboard focus when canvas is clicked
This commit is contained in:
Ian Gilman 2015-01-16 16:58:11 -08:00
commit 1765e3c0c9

View File

@ -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 );
@ -2310,6 +2312,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 ) {