custom Cell tracking in NSTableView

  • Hi,

    I have a NSTableView that has 2 columns. The last columns is a sort of
    search icon that is a NSButtonCell. When i click on the button, the
    cell is tracked but the row is also selected, is there any way to stop
    the selection from happening and just track the cell?

    thanks

    AC
  • Sure you can avoid to select the row.
    You have to add this method in the delegate class
    and return NO. You can also decide which row can or cannot be unselectable.

    - (BOOL)tableView:(NSTableView *)aTableView
                    shouldSelectRow:(NSInteger)rowIndex
    {
        return NO;
    }

    Of course you need later to identify the clicked row manually
    using mouseDown and keyDown in the NSTableView subclass.
    For example

    - (void)mouseDown:(NSEvent *)theEvent
    {
        NSPoint    curPoint = [self convertPoint:
                        [theEvent locationInWindow] fromView:nil];
        int        row = [self rowAtPoint:curPoint];
        int        col = [self columnAtPoint:curPoint];

        // do something with row and col;
    }

    Last, if you double click on the word e.g. "tableView" or "rowAtPoint" or
    "NSTableView" from your code you will be shown the NSTableView help page and
    know more and pick the methods you need.

    Best Regards
    --
    Lorenzo
    email: <archidea...>

    > Date: Thu, 25 Oct 2007 14:48:05 -0400
    > From: Alexander Cohen <alexcohen...>
    > Subject: custom Cell tracking in NSTableView
    > To: Apple CocoaList <cocoa-dev...>
    > Message-ID: <21FFD08A-2094-4D48-ACA1-E94B1DB2ED9F...>
    > Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
    >
    > Hi,
    >
    > I have a NSTableView that has 2 columns. The last columns is a sort of
    > search icon that is a NSButtonCell. When i click on the button, the
    > cell is tracked but the row is also selected, is there any way to stop
    > the selection from happening and just track the cell?
    >
    > thanks
previous month october 2007 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today