kleepklep Posted September 9, 2015 Share Posted September 9, 2015 I have an button in my game where I am popping a Facebook share window using Facebook SDK for JavaScript. When I interact with the popup and close it, the entire game show's a hand cursor and behaves as if it is the button. Anywhere I click on the screen will launch the popup again. I found that I can stop this behavior by adding the code at the bottom of this function, but then I have to click on the game to regain its focus before I can click on another button. Anyone have any ideas on how to deal with this? shareThis.inputEnabled = true;shareThis.input.useHandCursor = true;shareThis.events.onInputDown.add(function () { share(shareTitles[level - 1], shareMessages[level - 1], shareImgPath + 'icon_level' + level + '.jpg'); // I can stop the whole game acting like a button thing by doing this... shareThis.inputEnabled = false; shareThis.inputEnabled = true; shareThis.input.useHandCursor = true; // ...but then I have to click on the game once to regain its focus before I can interact with it again}); Link to comment Share on other sites More sharing options...
kleepklep Posted September 18, 2015 Author Share Posted September 18, 2015 I just figured out some trickery to deal with this!I noticed that when I click back onto the game and I'm over a button with an onInputOver listener it fires because the first click brings the game in focus, then the game reads that the pointer is over that button. game.input.activePointer.isDown reads as false even though the button is down so I can't use that, but game.input.activePointer.totalTouches reads as 0. So, if I put this in my onInputOver listeners it will read as if the button was pressed! if (!game.input.activePointer.totalTouches) { game.input.activePointer.totalTouches = 1; thisButton.onPressed();}This is a bit of a hack, so if there is another way to force the game back into focus so I don't have to do this please do share. Link to comment Share on other sites More sharing options...
kleepklep Posted September 21, 2015 Author Share Posted September 21, 2015 Unfortunately, this method turned out to be unreliable. Sometimes the game remains in focus even after interacting with the popup so just rolling over my button triggers the press. Ugh. Link to comment Share on other sites More sharing options...
Skeptron Posted September 21, 2015 Share Posted September 21, 2015 Did you try having an HTML popup and then give the focus to the canvas programmatically once closed? Link to comment Share on other sites More sharing options...
kleepklep Posted October 7, 2015 Author Share Posted October 7, 2015 I didn't bother because I tried everything under the sun to force focus back onto the canvas/Phaser game trying to solve a different issue (which was resolved in a Phaser update) and was never successful. Also, the popup is generated by Facebook's API, so I'm not sure that's even an option. Link to comment Share on other sites More sharing options...
Recommended Posts