The more projects I do in REALbasic, the feature that seems to keep making my life easier (user interface-wise, at least) is the lowly Container Control. Being able to create very complex, reusable controls keeps my windows orderly. Not having to duplicate the same UI on multiple windows is very powerful. And having their own events is useful as well. In fact, I use container controls as custom controls a lot.
Perhaps one of my newest discoveries is the EmbedWithin command. Using Container Controls it’s possible to add controls ON THE FLY. You can’t do this with regular controls unless you have one on the window already.
Here’s a BS example that I thought up. Say you created a wizard-like interface that had several decision points that take you along completely different paths. Using a pagepanel you could put the UI on each panel and just switch to the panel you need. You could even do it with container controls. But it’s probably overkill and creates overly complex code.
Instead, what you could do is at the decision point, simply figure out what the next panel should be, create a new instance of your container control and use EmbedWithin to add it to your window or panel. Each container control can then be queried for its settings and can be commanded to do their its tasks from your main window. It’s pretty easy to do.
Container Controls aren’t without their problems, Mac OS X controls have a tendency to bleed through a container control mask when in Carbon windows. It works better in composite windows, but well, composite windows are hosed right now. Hopefully this will get better with Cocoa support and all windows will be composite.
So what’s your favorite thing in REALbasic?