how to copy rows from NSTableView

泪湿孤枕 提交于 2019-12-23 19:31:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!