• 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
Re: selecting a single cell in NSTableView?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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:54:39 +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?
>
> Thanks,
>
> steve
>
Yes.You can do that.First you need to subclass NSTableView and override
mouseDown: method.And based on the location of the mouse you need to
find the selected cell row and column. Even you can give border to the
selected cell by - (void)tableView:(NSTableView *)aTableView
willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex . I think this is the only way to do.

-(void)mouseDown:(NSEvent *)event
{
selectedRow=[self rowAtPoint:[self convertPoint:[event
locationInWindow] fromView:nil]];
selectedColumn=[[self tableColumns] objectAtIndex:[self
columnAtPoint:[self convertPoint:[event
[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.

  • Prev by Date: Re:selecting a single cell in NSTableView?
  • Next by Date: Re: selecting a single cell in NSTableView?
  • Previous by thread: Re: selecting a single cell in NSTableView?
  • Next by thread: Re: selecting a single cell in NSTableView?
  • Index(es):
    • Date
    • Thread