• 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
Is there an easier way of changing NSButtonCell state in an NSOutlineView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Is there an easier way of changing NSButtonCell state in an NSOutlineView


  • Subject: Is there an easier way of changing NSButtonCell state in an NSOutlineView
  • From: Gilles Celli <email@hidden>
  • Date: Wed, 23 Nov 2011 16:58:34 +0100

Hello,

I've setup an NSOutlineView with 2 colums: the first one named "buttonColumns" with NSButtonCell (Switch ON / OFF)
and the second one with TextFieldCell…

While the state change works for NSButtonCell in the buttonColum I had to create an NSArray *checks to set it ON or OFF.
Is there an easier way to change the state of an NSButtonCell in an NSOutlineView without using an NSArray ?
The code I'm using seems a little bit overkill for me...there must be a simpler solution...

Here's what I've done so far and it works:

// init code

checks  = [[NSMutableArray alloc] init];
for ( int i=0; i <  NBR_OF_ROWS;  i++ )
        [checks addObject:[NSNumber numberWithInt:0]];

// NSOutlineView datasource methods

- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
{
    id theValue;
  NSInteger selectedRowIndex = [outlineView selectedRow];
   if ( [[tableColumn identifier] isEqualToString:@"buttonColumn"] )
   {
      theValue = [checks objectAtIndex:selectedRowIndex];
    }
    return theValue;
}

- (void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
{
    NSInteger selectedRowIndex = [outlineView selectedRow];

    if ( [[tableColumn identifier] isEqualToString:@"buttonColumn" ])
    {
       [checks replaceObjectAtIndex:selectedRowIndex withObject:object];
     }
}

Does someone have any clue ? Any help is greatly appreciated ?


Cheers,

Gilles

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Is there an easier way of changing NSButtonCell state in an NSOutlineView
      • From: Quincey Morris <email@hidden>
    • Re: Is there an easier way of changing NSButtonCell state in an NSOutlineView
      • From: Lee Ann Rucker <email@hidden>
  • Prev by Date: Problem getting NSTextView Ruler to update
  • Next by Date: Re: Weird NSTextField behavior on MBA.
  • Previous by thread: Problem getting NSTextView Ruler to update
  • Next by thread: Re: Is there an easier way of changing NSButtonCell state in an NSOutlineView
  • Index(es):
    • Date
    • Thread