Table view double-click actions

2006-06-19 17:37:00 UTC

It used to be that when you wanted to receive a double-click notification from an NSTableView, you had to do this in your -awakeFromNib:

[tableView setTarget:self];
[tableView setDoubleAction:@selector(doMagicThings:)];

Now, with the power of Bindings, you can do this in IB!

  1. Create an NSObjectController. Set its class name to the class of the desired receiver, and its “content” outlet (not binding) to the desired receiver.
  2. Bind the table view’s doubleClickTarget binding to the object controller. Controller key: content. Leave the model key path empty.
  3. Put the selector name in the field at the bottom of the binding view.

And a cheesy way that doesn’t involve a controller:

  1. Bind the table view’s doubleClickTarget binding directly to the receiver. Model key path: self.
  2. Put the selector name in the field at the bottom of the binding view.

UPDATE 2008-11-29: No need to add a -self method to your class or NSObject, as NSObject already has one. I think that the reason I didn’t see it before is because it’s declared in the NSObject protocol, not the NSObject class.

Leave a Reply

Do not delete the second sentence.