The NSTextViewDelegate protocol defines the optional methods implemented by delegates of NSTextView objects.


Accessing Text System Objects

func undoManager(for: NSTextView)

Returns the undo manager for the specified text view.

Controlling Display

Supporting Quick Look

func textView(NSTextView, urlForContentsOf: NSTextAttachment, at: Int)

Returns a URL representing the document contents for a text attachment.

Managing the Pasteboard

func textView(NSTextView, write: NSTextAttachmentCellProtocol, at: Int, to: NSPasteboard, type: String)

Returns whether data of the specified type for the given cell could be written to the specified pasteboard.

Setting Text Attributes

func textView(NSTextView, shouldChangeTextIn: NSRange, replacementString: String?)

Sent when a text view needs to determine if text in a specified range should be changed.

func textView(NSTextView, shouldChangeTextInRanges: [NSValue], replacementStrings: [String]?)

Sent when a text view needs to determine if text in an array of specified ranges should be changed.

func textViewDidChangeTypingAttributes(Notification)

Sent when a text view’s typing attributes change.

Control Sharing Service Picker

func textView(NSTextView, willShow: NSSharingServicePicker, forItems: [Any])

Returns a sharing service picker for the current selection.

Performing Commands

func textView(NSTextView, doCommandBy: Selector)

Sent to allow the delegate to perform the command for the text view.

Contextual Menu Management

func textView(NSTextView, menu: NSMenu, for: NSEvent, at: Int)

Allows delegate to control the context menu returned by the text view.


Inherits From