Hi all,
I am trying to find a better way to handle some code I really don’t like right now.
Ok - So, I have a basic hierarchy of a WebPage object and a container within it that is the main container. This container contains 3 items, 2 images and another container with the menu controls.
The menu controls need to instruct the main container to load in a new container and hide the menu (so the images are still visible through the new container)
Now, I have this working, but it is very convoluted with having to hand off references between the containers which is making it more and more confusing to track through the code.
Coming from iOS, I’d either setup delegation or setup a given object to listen for certain messages. I’m not sure how to replicate that here. I was first thinking of custom events, but I don’t see a nice way to handle that between two different objects that are in a has-a relationship (where the sub-object needs to send a message to its containing object).
So if you can imagine:
page---->MainContainer
|
|—> DataDisplay (dynamically created and embedded into the container)
DataDisplay needs to let the MainContainer know that the back button has been pushed so it can be unloaded and the actual main menu made visible and enabled. Right now this is handled through reference variables. If I can fire a custom event or send a message for the MainContainer to receive to act on, that would be ideal!