From 9ab8d5eb5fc4807aece01c426a7bcd61e2b011e6 Mon Sep 17 00:00:00 2001 From: Jeff Parsons Date: Sun, 23 Oct 2016 09:30:01 -0700 Subject: [PATCH] Trying to keep the focus code synced --- modules/pc8080/lib/computer.js | 2 +- modules/pcx86/lib/computer.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/pc8080/lib/computer.js b/modules/pc8080/lib/computer.js index ef4fd8634..115d23466 100644 --- a/modules/pc8080/lib/computer.js +++ b/modules/pc8080/lib/computer.js @@ -1405,7 +1405,7 @@ Computer8080.prototype.getMachineComponent = function(sType, componentPrev) * where the display is more constrained, so we no longer do it by default (fScroll must be true). * * @this {Computer8080} - * @param {boolean} [fScroll] + * @param {boolean} [fScroll] (true if you really want the control scrolled into view) */ Computer8080.prototype.updateFocus = function(fScroll) { diff --git a/modules/pcx86/lib/computer.js b/modules/pcx86/lib/computer.js index 10ecb2f4b..e611c7384 100644 --- a/modules/pcx86/lib/computer.js +++ b/modules/pcx86/lib/computer.js @@ -1432,7 +1432,8 @@ Computer.prototype.getMachineComponent = function(sType, componentPrev) * updateFocus(fScroll) * * NOTE: When soft keyboard buttons call us to return focus to the machine (and away from the button), - * the scroll feature has annoying effect on iOS, so we no longer do it by default (fScroll must be true). + * the browser's default behavior is to scroll the element into view, which can be annoying, especially on iOS, + * where the display is more constrained, so we no longer do it by default (fScroll must be true). * * @this {Computer} * @param {boolean} [fScroll] (true if you really want the control scrolled into view) @@ -1450,10 +1451,12 @@ Computer.prototype.updateFocus = function(fScroll) x = window.scrollX; y = window.scrollY; } + /* * TODO: We need a mechanism to determine the "active" display, instead of hard-coding this to aVideo[0]. */ this.aVideo[0].setFocus(); + if (!fScroll && window) { window.scrollTo(x, y); }