The nstext field does not have copy and paste functions. They are only in nstextview. The catch is that when editing a text field, it opens a text field called a field commentator during editing, and sets this as the first responder.
How to solve:
each text attached to it has a cell as a child. (ps is not a programmer, I call it a child)

The cell has a method for implementing a custom field editor called fieldeditorforview
class cell: NSTextFieldCell { override func fieldEditorForView(aControlView: NSView) -> NSTextView? { return ESPasteView() } }
this function allows you to insert your own nstextview
here is my custom nstextview
class ESPasteView: NSTextView, NSTextViewDelegate { override func drawRect(dirtyRect: NSRect) { super.drawRect(dirtyRect) } override func paste(sender: AnyObject?) { Swift.print("user tries to paste") super.pasteAsPlainText(nil) } }
excuse him quickly. but I work in my application. However, it was necessary to modify. Must work.
credit:
How to disable right-click context menus in NSTextField (Cocoa)?
and Ken Thomases who pointed out the field editor
source share