defold / editor2-issues

DEPRECATED
44 stars 4 forks source link

Properly detect canvas (game) focus and not just window focus in HTML5 (DEF-2520) #690

Open subsoap opened 7 years ago

subsoap commented 7 years ago

Currently HTML5 jsweb target ( via window.WINDOW_EVENT_FOCUS_LOST window.WINDOW_EVENT_FOCUS_GAINED ) detects if current window has focus or not, but this seems incorrect it should be the current window has focus + app canvas has focus. I'm not sure best way to do it, but document.activeElement does return the currently active element and it could be checked to see if the app canvas is active or not. Might be better solutions though.

To clarify why this is important, key input isn't given to game canvas unless it has focus. If game relies on keyboard input player needs to be able to told to click once to give focus. When clicking the standard fullscreen button focus on the canvas is lost.

AGulev commented 6 years ago

@erikangelin-king @subsoap solved in 1.2.128 ? https://forum.defold.com/t/defold-1-2-128-has-been-released/20139?u=agulev

subsoap commented 6 years ago

@AGulev Yes!

subsoap commented 6 years ago

Wait, actually, I think this is a different issue.

I think the issue is that the engine detects if the browser Window has focus, but not if the canvas has click focus. I'll have to make a new test.

britzl commented 6 years ago

DEF-2520