setEnabled on a NSView

  • with NSControl, one can use "setEnabled:" to enable and disable it's UI
    element easily. Is there a one step procedure to disables all the controls
    within a custom NSView?

    jake
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
  • Personally I created a category on NSView to solve this issue. It goes
    something like this, and seems to work just fine:

    //
    //  NSView-DisableSubsAdditions.m
    //  Can Combine Icons
    //
    //  Created by David Remahl on Tue Dec 25 2001.
    //  Copyright (c) 2001 Infinity-to-the-Power-of-Infinity. All rights
    reserved.
    //

    #import "NSView-DisableSubsAdditions.h"

    @implementation NSView(DisableSubsAdditions)

    - (void)disableSubViews
    {
        [self setSubViewsEnabled:NO];
    }

    - (void)enableSubViews
    {
        [self setSubViewsEnabled:YES];
    }

    - (void)setSubViewsEnabled:(BOOL)enabled
    {
        NSView* currentView = NULL;
        NSEnumerator* viewEnumerator = [[self subviews] objectEnumerator];

        while( currentView = [viewEnumerator nextObject] )
        {
            if( [currentView respondsToSelector:@selector(setEnabled:)] )
            {
                [(NSControl*)currentView setEnabled:enabled];
            }
            [currentView setSubViewsEnabled:enabled];

            [currentView display];
        }
    }

    @end

    / Sincerely, David

    > with NSControl, one can use "setEnabled:" to enable and disable it's UI
    > element easily. Is there a one step procedure to disables all the controls
    > within a custom NSView?
    >
    > jake
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
previous month february 2002 next month
MTWTFSS
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28      
Go to today