Protocol

NSTextViewDelegate

A set of optional methods that text view delegates can use to manage selection, set text attributes, work with the spell checker, and more.

Topics

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: NSPasteboard.PasteboardType)

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.

Relationships

Inherits From

See Also

Text Views

class NSTextField

Text that the user can select or edit and that sends its action message to its target when the user presses the Return key.

protocol NSTextFieldDelegate

A method that a text field delegate can use to control its field editor action menu.

class NSTextView

A view that draws text and handles user interactions with that text.

class NSText

The most general programmatic interface for objects that manage text.