By default, double-clicking triggers renaming in NSTableView.
How can I let double-clicking instead trigger my own custom开发者_StackOverflow社区 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.
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.
You must make the text cell uneditable in order for your table view to get a double-click action message.
精彩评论