Re: Enabling/Disabling Control view hiearchies
Re: Enabling/Disabling Control view hiearchies
- Subject: Re: Enabling/Disabling Control view hiearchies
- From: "Mark A. Stratman" <email@hidden>
- Date: Fri, 18 Jun 2004 16:35:05 -0500
Before bindings, I never found (though I'll admit I didn't
whole-heartedly search) a good way to enable/disable groups of
controls.
With bindings, however, it's quite simple and relatively elegant. For
every control you want to group together, bind its "enabled" property
to the same key within a controller.
Then just modify that key to enable/disable those controls.
Example: [theController setValue:[NSNumber numberWithBool:YES]
forKey:@"groupFooEnabled"];
- Mark
On Jun 18, 2004, at 4:15 PM, Scott Thompson wrote:
I'm trying to set up a scheme whereby I can enable and disable a group
of related controls all at once. Under most of the application
frameworks that I am more familiar with (Carbon/HIView, PowerPlant,
etc...) one can set up a view hierarchy of controls and then
enable/disable the parent view to change the enabled state of the
children. Most are clever enough that when you reenable the parent
view, if any of the children were enabled before the parent was
disabled, then those "latently enabled" controls will be enabled
again.
If I'm reading things properly, however, Cocoa distinguishes itself
from those other frameworks in that NSView doesn't have the concept of
being enabled. You don't see enabling behavior in the hierarchy until
you get to NSControl.
This, however, begs the question of how to group controls so that they
enable or disable together (i.e. if I turn on this checkbox then I
enable all the controls related to it).
As far as I can tell, you have to do something like maintain IB
outlets that point to the controls (including static text labels) and
then enable/disable them one-by-one.
I thought to group the controls inside of an NSBox that had no border,
but NSBox doesn't seem to understand enabling or disabling itself (and
it's subviews) either.
Given the elegance of the rest of the framework, I can only think that
I must have misunderstood something. Can anyone help me out by
describing the expected strategy for enabling/disabling controls, or
by pointing me to the appropriate documentation?
Scott
_______________________________________________
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.
_______________________________________________
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.