Browse Source

deal with focus issues

Gregg Tavares 6 years ago
parent
commit
89adb34886

+ 4 - 0
threejs/threejs-game-conga-line-w-notes.html

@@ -343,6 +343,10 @@ function main() {
       }
 
       uiElem.addEventListener('mousedown', (e) => {
+        // this is needed because we call preventDefault();
+        // we also gave the canvas a tabindex so it can
+        // become the focus
+        canvas.focus();
         handleMouseMove(e);
         window.addEventListener('mousemove', handleMouseMove);
         window.addEventListener('mouseup', handleMouseUp);

+ 4 - 0
threejs/threejs-game-conga-line.html

@@ -343,6 +343,10 @@ function main() {
       }
 
       uiElem.addEventListener('mousedown', (e) => {
+        // this is needed because we call preventDefault();
+        // we also gave the canvas a tabindex so it can
+        // become the focus
+        canvas.focus();
         handleMouseMove(e);
         window.addEventListener('mousemove', handleMouseMove);
         window.addEventListener('mouseup', handleMouseUp);

+ 4 - 0
threejs/threejs-game-player-input.html

@@ -307,6 +307,10 @@ function main() {
       }
 
       uiElem.addEventListener('mousedown', (e) => {
+        // this is needed because we call preventDefault();
+        // we also gave the canvas a tabindex so it can
+        // become the focus
+        canvas.focus();
         handleMouseMove(e);
         window.addEventListener('mousemove', handleMouseMove);
         window.addEventListener('mouseup', handleMouseUp);