Re:selecting a single cell in NSTableView?
Re:selecting a single cell in NSTableView?
- Subject: Re:selecting a single cell in NSTableView?
- From: Ramesh PVK <email@hidden>
- Date: Thu, 29 Jan 2004 10:48:15 +0530
>
I'm trying to implement a multi-row, multi-column table where I can
>
select a single cell in a row instead of the entire row. NSTableView
>
seems to be very row-oriented in that clicking on one cell selects the
>
entire row. Is NSTableView the way to do this, or is there a better
>
table type class that already does what I want to do? If NSTableView
>
will do it, what do I need to do to get this behavior?
>
Yes .Yo can do that .First you need to subclass NSTableView and
override mouseDown: method . With the location of the mouse down you
need to calculate the selected cell row and the column index. Yo can
even give border to the selected cell with the delegate method
tableView:::. I think this is the only way to achieve this.
-(void)mouseDown:(NSEvent *)event
{
selectedRow=[self rowAtPoint:[self convertPoint:[event
locationInWindow] fromView:nil]];
selectedColumn=[[self tableColumns] objectAtIndex:[self
columnAtPoint:[self convertPoint:[event locationInWindow]
fromView:nil]]];
[super mouseDown:event];
}
- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell
forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
{
if(rowIndex==selectedRow && [aTableColumn isEqualTo:selectedColumn])
[aCell setBordered:YES];
else
[aCell setBordered:NO];
}
--Ramesh
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.