• 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:40:56 -0700

Followup:

I just tested this, and it works fine; in fact, I added it to my base
framework. However, you'll need to change the -superviewIsEnabled
method as shown:

- (BOOL)superviewIsEnabled
{
NSView *superview;
if ((superview = [self superview])) {
return [superview isEnabled];
}
return YES;
}

I'd written it correctly at first, and it apparently got fuxored during
an undo/redo while editing in Mail.app.

Good luck!
--
Shaun Wexler
MacFOH
http://www.macfoh.com


On Jun 18, 2004, at 3:00 PM, Shaun Wexler wrote:

> 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.


References: 
 >Enabling/Disabling Control view hiearchies (From: Scott Thompson <email@hidden>)
 >Re: Enabling/Disabling Control view hiearchies (From: Shaun Wexler <email@hidden>)

  • Prev by Date: bad behavior of slider (circular)
  • Next by Date: NSBox Border with buttons and missing elements in view order
  • Previous by thread: Re: Enabling/Disabling Control view hiearchies
  • Next by thread: Context Menu disables clicks in NSQuickDrawView
  • Index(es):
    • Date
    • Thread