Re: Hiding an NSControl
Re: Hiding an NSControl
- Subject: Re: Hiding an NSControl
- From: Henry McGilton <email@hidden>
- Date: Wed, 3 Sep 2003 16:54:10 -0700
On Wednesday, September 3, 2003, at 04:17 PM, John Stiles wrote:
On Wednesday, September 3, 2003, at 03:57 PM, Alastair J.Houghton
wrote:
On Wednesday, September 3, 2003, at 10:50 pm, John Stiles wrote:
I'm a bit of a neophyte when it comes to Cocoa, so please bear with
me. I've been writing a Cocoa app for the last two months, and
usually a few good books and developer.apple.com are good enough to
answer any questions I have, but this one has me and a coworker both
stumped.
What's the easiest way to hide an NSControl?
The usual answer is to remove it from its superview. However, you
should seriously consider whether you should be hiding a control in
the first place... users often find user-interface elements that
vanish confusing; especially if it isn't obvious how to get them back
again. (I had an experience exactly like this the other day with
Apple's Shark tool... I lost the PPC970 instruction group display ;-)
[found it again now, though].)
If I remove it from the superview, how do I bring it back? Will
addSubview: put it back in the right place?
Yes --- if you keep the frame rectangle of the control the same as when
it was created,
addSubview should place it back in the same position.
FWIW, this won't affect end-user experience. All the control showing
and hiding will happen before the NSWindow ever appears. It's a block
of checkboxes, and sometimes we need four of them, and sometimes we
need fewer.
I concur with Alastair's post on this subject. In general, you should
give very careful consideration to hiding controls, and instead think of
enabling and disabling them as required. Use analogies with your real
everyday world --- you would expect that the furniture in your living
room stays in the same positions whether the lights are on or off, or
whether the
time is morning or afternoon, and so on.
Best Wishes,
........ Henry
===============================+============================
Henry McGilton, Boulevardier | Trilithon Software
Objective-C/Java Composer | Seroia Research
-------------------------------+----------------------------
mailto:email@hidden |
http://www.trilithon.com
|
===============================+============================
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.