Popups Reopening After Screen Cange

I have a popup where a user can select what type of campaign they want to play, this works perfectly and takes them into the campaign where they can play, my problem is that when the user presses escape to bring up the pause menu and then quit the level, the gotoScreen method is called and the menu is shown again but the campaign choice popup reopens, is there a way to stop this from happening?

Popups are not constrained to a single screen, so you have to make sure you close the popup with nifty.closePopup(myPopup.getId()) when the user exits from it (hitting ok, or cancel or whatever other buttons you have in it). Also not posting any of your code lessens the chance of someone helping you out dramatically, we just have to guess what might be wrong.

Nifty popups can be problematic (unless void has fixed them in the past 6 months).



Don’t try and change screen while the popup is closing. do close with a callback, then switch screen once your callback hits to say the close is complete.

1 Like
@zarch said:
Nifty popups can be problematic (unless void has fixed them in the past 6 months).

Don't try and change screen while the popup is closing. do close with a callback, then switch screen once your callback hits to say the close is complete.


Thank you so much, I've been pulling my hair out over this for the last few days!

Happy to help :slight_smile:



I ran into similar problems myself.

Actually he did fix it:



https://github.com/void256/nifty-gui/commit/3da01269541232e11ca414cae6dc4735df034c43



:slight_smile:

2 Likes
@zarch said: Nifty popups can be problematic (unless void has fixed them in the past 6 months).

Don’t try and change screen while the popup is closing. do close with a callback, then switch screen once your callback hits to say the close is complete.

What do you mean by “close with a callback”?

Never mind, it’s been fixed :slight_smile:

But I meant that when you tell it to close you can add a listener that gets called back when the close completes.