• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Enabling/Disabling Control view hiearchies
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Enabling/Disabling Control view hiearchies


  • Subject: Re: Enabling/Disabling Control view hiearchies
  • From: Shaun Wexler <email@hidden>
  • Date: Fri, 18 Jun 2004 15:00:05 -0700

On Jun 18, 2004, at 2: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. 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?

If all controls and cells follow convention and manage state using
accessor methods, you can add a category to NSView, and poseAs
NSControl (and subclasses, as necessary) to enforce its use. Example
(untested, written in Mail.app):

@interface NSView (EnabledState)
- (BOOL)superviewIsEnabled;
- (BOOL)isEnabled;
- (void)setEnabled:(BOOL)enabled;
- (BOOL)enabled;
@end

@implementation NSView (EnabledState)

- (BOOL)superviewIsEnabled
{
return [[self superview] isEnabled];
}

- (BOOL)isEnabled
{
return YES; // Override in subclasses.
}

- (void)setEnabled:(BOOL)enabled
{
// NOP. Override in subclasses, to set ivar.
}

- (BOOL)enabled // KVC/bindings support
{
return [self isEnabled];
}

@end

@interface PosedNSControl : NSControl {}
@end

@implementation PosedNSControl

+ (void)load
{
[self poseAsClass:[NSControl class]];
}

- (BOOL)isEnabled
{
return [super isEnabled] && [self superviewIsEnabled];
}

@end
--
Shaun Wexler
MacFOH
http://www.macfoh.com

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.


  • Follow-Ups:
    • Context Menu disables clicks in NSQuickDrawView
      • From: John Pattenden <email@hidden>
    • Re: Enabling/Disabling Control view hiearchies
      • From: Shaun Wexler <email@hidden>
References: 
 >Enabling/Disabling Control view hiearchies (From: Scott Thompson <email@hidden>)

  • Prev by Date: Re: How can I add custom headers for a library?
  • Next by Date: bad behavior of slider (circular)
  • Previous by thread: Re: Enabling/Disabling Control view hiearchies
  • Next by thread: Re: Enabling/Disabling Control view hiearchies
  • Index(es):
    • Date
    • Thread