Re: Hiding a view
Re: Hiding a view
- Subject: Re: Hiding a view
- From: Mason Mark <email@hidden>
- Date: Thu, 25 Oct 2001 15:48:29 -0700
--On Thursday, October 25, 2001 11:36 AM -0700 Dustin Mierau
<email@hidden> wrote:
Morning people.
Damn, I thought this was a simple question...
Yeah, this comes up periodically.
Originally (when I was starting with Cocoa), I thought this was a stupid
omission not to have a show/hide API. I still think the stated reasons for
it (principle of least surprise / always show the user everything and
nothing should disappear) are not valid ones in the context of justifying
why such an API is not provided.
They might describe a good ideal scenario, but modern software certainly
has thousands of legitimate reasons to make things appear and go away on
screen.
However, I now *love* Cocoa's way of doing this, mainly because, as
somebody else mentioned in this thread, when you make a view disappear, you
are conceptually "removing" it from the window. By actually removing the
view from the window, you are also removing it from the event processing
chain, so the window never has to think about its "hidden" views.
If the view to be hidden might change its size or position, using
-replaceSubview:with: to replace the view with a simple NSView that clones
the disappearing view's size and sizing attributes is a very convenient way
to do it.
--
Mason
P.S.
As Erik Buck pointed out, in your particular case you should just set the
text of the view, though...