NSTableHeaderCell detect mouse down?

619 views Asked by At

I'm attempting to customize a NSTableHeaderCell to detect mouse clicks. In the past i've used things such as an NSTrackingArea or overriding the mouseDown event such as:

-(void)mouseDown:(NSEvent *)theEvent
{
    NSLog(@"Mouse down");
}

These methods don't seem to work properly on a NSTableHeaderCell as its a cell rather than a view.

Does anyone have any suggestions on detecting mouse events on a cell? Specifically I would like to catch the first click (along with its location).

1

There are 1 answers

1
Jay On

The way this is designed to be handled by AppKit is via your NSTableViewDelegate and

tableView:mouseDownInHeaderOfTableColumn:
'Tells the delegate that the mouse button was clicked in the specified table column’s header.'

Unless you have very specific needs to actually handle the mouse-down in your cell it might be easier to just implement that method in your delegate.