فهرست منبع

deal with focus issues

Gregg Tavares 6 سال پیش
والد
کامیت
89adb34886
3فایلهای تغییر یافته به همراه12 افزوده شده و 0 حذف شده
  1. 4 0
      threejs/threejs-game-conga-line-w-notes.html
  2. 4 0
      threejs/threejs-game-conga-line.html
  3. 4 0
      threejs/threejs-game-player-input.html

+ 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);