On Saturday, December 7, 2002, at 04:19 PM, Trey Harris wrote:

Can someone tell me how to hide views? That is, in IB, I create all the
elements of my interface, but some of them I want to not be displayed when
the app starts and I want to display them later. This seems like it
should be an easy problem to solve.
It seems like it should be, yes. The problem is, Apple's Human Interface Guidelines advise against it, and in order to encourage adherence to the HIG, they've apparently made it more difficult than it should be. :-(

I assume that you're using one of the label variants of an NSTextField, perhaps as a status display or something similar. This is one of many cases where it's hiding a view until it's needed is, regardless of what Apple says, a perfectly valid need. Fortunately, for this particular case anyway, there's an easy workaround. :-)

In IB, bring up the window's inspector panel, and uncheck the "Visible at launch time" option. This has the effect of causing the window to be hidden when the NIB is first loaded. It's been loaded, and it's accessible via code, but it's hidden until you explicitly make it visible.

After initializing TheText with a blank string, you can then make the window visible like this:

$self->{'Window'}->makeKeyAndOrderFront(undef);

This can be a useful technique for many sorts of initialization that you may want to do before displaying your main window - populating drop-down lists, reading user defaults, etc. If you're doing enough of that sort of thing that there's a non-trivial pause before the window comes up, you could add a "splash" panel, perhaps with a progress view, that's visible immediately, and hide it immediately after displaying the main window. Assuming the splash panel is connected to an outlet named "SplashPanel", you'd hide it with:

$self->{'SplashPanel'}->orderOut(undef);

Note that orderOut() doesn't unload the window, it simply makes it invisible - it and its contents are still accessible through any connected outlets.

sherm--

If you listen to a UNIX shell, can you hear the C?



Reply via email to