Jump to content

Question about HTML5 game focus


General Disarray
 Share

Recommended Posts

Hello, I don't know much about HTML5, so this may be a dumb question for most of you. 

Let's suppose that we have an HTML5 game that is inside a web page where you can click a button to make it full screen if you want. With either choice, in order to start the game, the users have to click inside the game canvas to give mouse focus to the game. If they don't, then they can move the mouse pointer around, but they are restricted to the edges of the screen, when the mouse pointer stops at the edge, the lookaround inside the game stops as well. When they click inside the canvas of the game, a message shows up from the browser saying "windows.net has control of your pointer. Press Esc to take back control."

The user basically walks around a gallery with paintings on the walls. When the user is in front of a painting, he or she clicks the left mouse button, and a full screen overlay appears with some information, it's something called a "widget". At this point, the game has a command to show the mouse pointer, because some of these overlays have hyperlinks that will open websites in the user's default browser.

The way this is intended to work, and it does perfectly in the game engine (Unreal Engine 4.23) and builds to both macOS and Win64, is that when the user clicks the right mouse button, the full screen overlay closes and the user is back on the game, where he or she can keep walking around and taking a look at other paintings. The problem I have is that when the user left clicks on the painting and this opens the overlay and also shows the mouse pointer, that releases the mouse focus from the game to the system. And in the HTML5 version, when the user closes the overlay, the mouse focus doesn't return to the game, it stays in the system. This is a huge problem for me because I need the focus to go back to the game, because if the user left clicks in the same position, then the overlay will open again, and it will be confusing. I know this thing so I know that I can walk back until I'm not close to the painting and then click, and I will go back in the game without triggering the overlay to open.

So since the game works as intended in every other way, and only does this in HTML5, it seems to me that this is a restriction browsers have, for which they don't allow any code to grab the mouse focus unless the user clicks inside it first. Am I making a correct assumption?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...