I have a pattern that I was using when coding with Objective-C to use the postNotification to pass data back to a scene just prior to calling popScene (i.e., getting data back to the previous scene). My pattern is to have sceneA that calls pushScene with sceneB, passing it data as parameters in the sceneB::createScene. Then when sceneB is done, just prior to calling popScene, I send a notification with data collected in sceneB. That notification is listened for in sceneA, so two things essentially happen when the popScene is calling sceneB: sceneB goes away and sceneA listener gets called and then calls the appropriate method in SceneA. So, now as I am porting over to C++ and using the dispatchEvent with a EventCustom prior to the popScene in sceneB, the sceneB goes away but the listener for sceneA doesn’t get called, hence doesn’t see the EventCustom, hence doesn’t trigger the method to act when sceneB is done.
My guess is that the pushScene executed in SceneA pauses the listener for SceneA, and when the event is dispatched, it happens while sceneA is still paused, so it doesn’t see the event. Then the pop scene happens and SceneB goes away, but the method that is supposed to be triggered that will accept the data from sceneB doesn’t get called. I have used onEnter in sceneA, but I can’t pass data from SceneB to SceneA. I image I can use the UserDefaults in SceneB and write out the values I want to transfer back and then in SceneA::onEnter read the values of UserDefaults. But I doubt that is the purpose of UserDefaults.
So, my question, how do you get data passed back to a prior scene before the popScene?
NOTE: I have searched and found all kinds of ways to pass data from SceneA to SceneB, but nothing to pass data BACK from SceneB to SceneA. (without resorting to using replaceScene in both directions).