views:

38

answers:

2

By default, double-clicking triggers renaming in NSTableView.

How can I let double-clicking instead trigger my own custom code (such as opening the double-clicked file)?

And also: How can I let the renaming be like in Finder, where you first single click, and then click again and quickly move the mouse pointer away? That is how renaming gets triggered in the Finder. I want it like that in NSTableView.

+2  A: 

According to the documentation, NSTableView has -setDoubleAction:. Clicking once to select a row, then clicking a text cell to edit behaves like the Finder by default (and neither this nor Finder have anything to do with moving the pointer quickly away - try it).

Click once to select, then click again to begin rename. Click twice (fast enough to be a double-click) and it handles the "double" action.

Joshua Nozzi
+1  A: 

You must make the text cell uneditable in order for your table view to get a double-click action message.

JWWalker
Untrue. Growl's BeepHammer example application has both column and cell set to editable, and double-clicking works just fine in it.
Peter Hosey
I don't know about that example, but the documentation for `-[NSTableView setDoubleAction:]` says "If the double-clicked cell is editable, this message isn’t sent and the cell is edited instead."
JWWalker
You're right, that is what one would think judging from the documentation. But it seems the documentation is in this case erroneous. Looks like this works even if the cell is editable.
Enchilada