Table view double-click actions
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!
- Create an NSObjectController. Set its class name to the class of the desired receiver, and its “content” outlet (not binding) to the desired receiver.
- Bind the table view’s doubleClickTarget binding to the object controller. Controller key: content. Leave the model key path empty.
- Put the selector name in the field at the bottom of the binding view.
And a cheesy way that doesn’t involve a controller:
- Bind the table view’s doubleClickTarget binding directly to the receiver. Model key path: self.
- 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.