I'm in a crunch: working on a game-jam project, and something which I once could do, no problem, no longer works.
The project is Desktopia which is a PC idle game that only takes up the bottom section of your screen. Well, except when you need stats or construction menus, which are presented in separate windows. For this, I'm using HTML popups and referencing the main window with window.opener. Here's an image of what I mean:
I have onsceen buttons to access these menus but I also want to be able to use keys. Example: 'B' for build. That was easy to set up, but once I click 'B', the main window loses focus, so clicking 'B' again does nothing. To fix this I added event listeners to the new windows, which is fine pressing 'B' on any window will now open/close the build menu.
The big issue: once I've clicked 'B' and focus moves over to the other window, if I want to move my character, I have to re-click on the main window! (this is very user-unfriendly. I can't set event listeners on the popups to main window.focus() because popups aren't allowed to steal focus control. Years ago you just had to window.blur() prior to focus, but that has been patched out. Even setting the main window with an alert will not regain focus until you click it!
How I'm managing it right now is by running the main game's functions (move, attack, etc.) THROUGH the popups. An absolutely ridiculous solution.
Does anybody know a way to regain a parent window's focus from a popup? For what it matters, I'm using the most up to date nwjs with chromium.
The project is Desktopia which is a PC idle game that only takes up the bottom section of your screen. Well, except when you need stats or construction menus, which are presented in separate windows. For this, I'm using HTML popups and referencing the main window with window.opener. Here's an image of what I mean:
The big issue: once I've clicked 'B' and focus moves over to the other window, if I want to move my character, I have to re-click on the main window! (this is very user-unfriendly. I can't set event listeners on the popups to main window.focus() because popups aren't allowed to steal focus control. Years ago you just had to window.blur() prior to focus, but that has been patched out. Even setting the main window with an alert will not regain focus until you click it!
How I'm managing it right now is by running the main game's functions (move, attack, etc.) THROUGH the popups. An absolutely ridiculous solution.
Does anybody know a way to regain a parent window's focus from a popup? For what it matters, I'm using the most up to date nwjs with chromium.