NSOutlineView - display NSButtonCell only for leaf node with outlineView:dataCellForTableColumn:item: method
NSOutlineView - display NSButtonCell only for leaf node with outlineView:dataCellForTableColumn:item: method
- Subject: NSOutlineView - display NSButtonCell only for leaf node with outlineView:dataCellForTableColumn:item: method
- From: Gilles Celli <email@hidden>
- Date: Sun, 02 Oct 2011 22:14:40 +0200
Hi,
I've setup an NSOutlineView which displays items of a data acquisiton system this way
+-LocationName
+--InstrumentNameA
+----DataTypeNameA1
+----DataTypeNameA2
+----DataTypeNameA3
+
+--InstrumentNameB
+----DataTypeNameB1
+----DataTypeNameB2
…
So as you see the DataTypes (like Voltage) is a child of an Instrument (e.g: Voltmeter)...
Now I want to have a NSButtonCell for all the DataTypeNames (leaf node of the OvItem items class)…I've setup an NSOutlineView with 2 columns: first column named
"buttonColumn" and a second one to display the Items…
I've tried to generate the buttons with the NSOutlineView delegate method "outlineView:dataCellForTableColumn:item:" but it just show all the buttons
for every row/items:
Here's what I tried so far:
- (NSCell *)outlineView:(NSOutlineView *)outlineView dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
//printf("delegate column identifier: %s\n", [[tableColumn identifier] cStringUsingEncoding:NSASCIIStringEncoding]);
NSCell* returnCell = [tableColumn dataCell];
NSTableColumn *checkboxColumn = [outlineViewChannels tableColumnWithIdentifier:@"buttonColumn"];
if ( ![(OvItem *)item isGroup] )
{
if ( [[tableColumn identifier] isEqualToString:@"buttonColumn"] )
{
NSButtonCell *cell = [[NSButtonCell alloc] init];
[cell setButtonType:NSSwitchButton];
[cell setTitle:@""];
[cell setEnabled:YES];
[cell setTransparent:NO];
[checkboxColumn setDataCell:cell];
[cell release];
}
}
return returnCell;
}
I've even tried with another delegate method: outlineView:willDisplayCell:forTableColumn:item: but this didn't work either and takes a lot of overhead since it
refreshes everytime the user clicks / scrolls in the outline view...
Does someone have a clue how I can fix this ?
Any suggestion(s) are greatly appreciated,
--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