Making NSCell invisible in an NSOutlineView
Making NSCell invisible in an NSOutlineView
- Subject: Making NSCell invisible in an NSOutlineView
- From: Sunil Vemuri <email@hidden>
- Date: Wed, 6 Apr 2005 19:16:08 -0400
I'm looking to make an NSCell in a column of an NSOutlineView invisible
depending upon the row/node. The checkbox is simply not relevant to
certain rows/nodes. Below is how I instantiate the checkbox and how I
*disable* the checkbox on a per-row basis. I would prefer that nothing
be shown instead of a disabled checkbox.
- (void)awakeFromNib
{
NSTableColumn* col = [outlineView tableColumnWithIdentifier:@"col1"];
if (col) {
NSButtonCell* checkBox = [[[NSButtonCell alloc] init] autorelease];
[checkBox setButtonType:NSSwitchButton];
[checkBox setTitle:@""];
[checkBox setRefusesFirstResponder:YES];
[checkBox setControlSize:NSSmallControlSize];
[col setDataCell:checkBox];
}
}
- (void)outlineView:(NSOutlineView *)olv willDisplayCell:(NSCell *)cell
forTableColumn:(NSTableColumn *)tableColumn item:(id)item {
NSString *identifier = [tableColumn identifier];
if ([identifier isEqualToString:@"col1"]) {
if (![item isVisible]) {
[cell setEnabled:NO]; // <-- This disables the checkbox
successfully
// [cell setVisible:NO]; // <-- wouldn't it be nice if this could
be done
}
}
}
I understand the issue of making a control invisible has been discussed
and I have read through the related threads that I could find (cited
below; apologies if I missed some other relevant thread). However, I
did not see this particular issue (an NSCell in an NSOutlineView or
NSTableView) covered. Is there a mechanism to make the NSCell
invisible or selectively display a different cell based on the row?
http://lists.apple.com/archives/cocoa-dev/2002/May/msg01735.html
http://cocoa.mamasam.com/MACOSXDEV/2002/02/2/25625.php
Thanks in advance,
--Sunil
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden