NSSegmentedCell in NSOutlineView troubles
NSSegmentedCell in NSOutlineView troubles
- Subject: NSSegmentedCell in NSOutlineView troubles
- From: Benjámin Salánki <email@hidden>
- Date: Mon, 22 Aug 2005 08:58:30 +0200
Dear List,
I searched through the archives, but couldn't find anything that
helped me solve my problem which is the following:
My project is a Tiger project and I have set up one of the
NSOutlineView columns to use NSSegmentedCells as the dataCell. In my
awakeFromNib method I set the thing up like this:
[(NSSegmentedCell*)[[outlineView
tableColumnWithIdentifier:@"name"] dataCell] setLabel:@"one"
forSegment:0];
[(NSSegmentedCell*)[[outlineView
tableColumnWithIdentifier:@"name"] dataCell] setLabel:@"two"
forSegment:1];
[(NSSegmentedCell*)[[outlineView
tableColumnWithIdentifier:@"name"] dataCell] setLabel:@"three"
forSegment:2];
[(NSSegmentedCell*)[[outlineView
tableColumnWithIdentifier:@"name"] dataCell] setLabel:@"four"
forSegment:3];
Now how do I get to know which of the NSSegmentedCells was clicked? I
tried to add
[(NSSegmentedCell*)[[outlineView
tableColumnWithIdentifier:@"name"] dataCell] setTarget:self];
[(NSSegmentedCell*)[[outlineView
tableColumnWithIdentifier:@"name"] dataCell] setAction:@selector
(validateType:)];
I thought this action would be sent out by the NSSegmentedCells, but
when I tried setting up the validateType: method it revealed that the
sender of the action was in fact the NSOutlineView. Which was
strange. So I tried the
- (void)outlineView:(NSOutlineView *)theOutlineView setObjectValue:
(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
method, to check stuff. I used the following code:
NSSegmentedCell* segCell = [[tableColumn dataCellForRow:
[theOutlineView rowForItem:item]] retain];
if([segCell isSelectedForSegment:[segCell selectedSegment]])
{
//this should get me the last selected segment if it
is selected
}
else
{
//this should get me the last selected segment if it
is not selected
}
[segCell release];
segCell = nil;
I hope I got the way this is supposed to work, but for some strange
reason, whatever NSSegmentedCell I click it turns out that my app
thinks that I always click the last segment, i.e. the one with the
label @"four".
could anyone point me in the right direction?
thanks,
Ben
_______________________________________________
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