• 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: Daryn <email@hidden>
  • Date: Thu, 29 Jan 2004 01:01:57 -0600

Using NSMatrix would be far easier than hacking up a table view to
perform your desired behavior.

If you really wanted to hack up a table, I'd override
highlightSelectionInClipRect:. In the mouseDown, calculate the
intersection of rectOfColumn: & rectOfRow:, and then intersect this
against the clipRect in the highlight method.

On Jan 28, 2004, at 11:18 PM, Ramesh PVK wrote:

>> 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.

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.

References: 
 >Re:selecting a single cell in NSTableView? (From: Ramesh PVK <email@hidden>)

  • Prev by Date: Calculating paragraph numbers
  • Next by Date: Re: Changing the Window level upon dragging.
  • Previous by thread: Re:selecting a single cell in NSTableView?
  • Next by thread: Re: selecting a single cell in NSTableView?
  • Index(es):
    • Date
    • Thread