Search code examples
objective-ccocoanstableview

Handle Double-click Mouse Event and Return Pressed for NSTableView


OK, what I need is pretty straightforward, though I can still find nothing specific.

I want to be able to :

  • track double-click events
  • track when the NSTableView is in focus, and the "Return" key is pressed.

How would you go about it?

P.S. I've had a look into NSTableViewDelegate specification, but I can't find anything useful.


Solution

  • For double click you need to do just these :

    -(void)awakeFromNib{
        [self.tableView setDoubleAction:@selector(thisMethod)];
        //And if you wish to take selector dynamically, I guess you know how to do :)
    }
    
    -(void)thisMethod{
        NSLog(@"double clicked");
    }