问题
I have one NSTableView, Which displays just the row of numbers. I just want to copy those numbers using (cmd+copy) or right click copy. How can I achieve this feature in NSTableViews.
回答1:
By default, the edit menu (cut/copy/paste/etc) is auto-enabled, provided the text in your tableView row is selectable or editable, and the text field in question is in the responder chain.
The auto-enabled menu items work by looking at the responder chain. If the 1st responder responds to the selector that the menu item is tied to, the menu item is enabled. If the 1st responder doesn't respond to the selector of a given menu item, the menu item is disabled
You'll want to make sure the text field element in your table cell/view is selectable (you can turn this on/off in interface builder), also make sure your text field acceptsFirstResponder (might be called allowsFirstResponder, I'm going by memory)
来源:https://stackoverflow.com/questions/3733209/how-to-copy-rows-from-nstableview