Re: Hiding a view
Re: Hiding a view
- Subject: Re: Hiding a view
- From: Rainer Brockerhoff <email@hidden>
- Date: Thu, 25 Oct 2001 15:35:30 -0200
From: "Erik M. Buck" <email@hidden>
Date: Thu, 25 Oct 2001 10:00:29 -0500
Before you get all indignant, perhps you should consider that views should
not be disapearing and reapearing to the suprise of the user.
A good point, but there are times when you want them to appear and
disappear at the user's request - when the user clicks on a
disclosure button or triangle, for instance.
Here is code to add -setIsVisible: and -isVisible to every NSView in your
application, but before you look at the code, read why it is a bad idea.
Also consider that adding and removing subviews is the approved technique.
That is how tab views work for example.
Due to my experience with PowerPlant I too wanted to hide/unhide
views at first, but now am a convert to the new order :-)
From: "Erik M. Buck" <email@hidden>
Date: Thu, 25 Oct 2001 10:11:33 -0500
When you want to hide a view, replace it with an empty view (a NSBox or just
an NSView) that is the same size and has the same resizing options.
When you want to restore a view, replace the empty view with your view
making sure the size is the same as the view being replaced.
This will make sure that resizing works even when the view is hidden.
Thanks, Erik. That's a very nice tip. I'll check out what happens
when the window shrinks to hide the empty view's space... depending
on the autosizing flags it may cause side-effects.
Date: Thu, 25 Oct 2001 11:36:09 -0400
From: email@hidden
changing the position of the view will hide it from your eyes, but it
will still be in the responder chain, probably not what you want,
right ? if it's a textfield, and accept key event, you will have to
handle it as well. And if it's a button that accept key shortcut, then
again you have to work around.
Yes, the responder chain would be a problem solved only by removing.
So far I haven't had to do it.
--
Rainer Brockerhoff <email@hidden>
Belo Horizonte, Brazil
"Originality is the art of concealing your sources."
http://www.brockerhoff.net/ (updated Oct. 2001)