Kyle
Kyle

Reputation: 17677

NSTableHeaderCell detect mouse down?

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

Upvotes: 1

Views: 640

Answers (1)

Jay
Jay

Reputation: 6638

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.

Upvotes: 2

Related Questions