textView(_:shouldChangeTextInRanges:replacementStrings:)
Sent when a text view needs to determine if text in an array of specified ranges should be changed.
Declaration
@MainActor optional func textView(_ textView: NSTextView, shouldChangeTextInRanges affectedRanges: [NSValue], replacementStrings: [String]?) -> BoolParameters
- textView:
The text view sending the message. This is the first text view in a series shared by a layout manager, not necessarily the text view displaying the selected text.
- affectedRanges:
The array of ranges of characters to be replaced. This array must be a non-nil, non-empty array of objects responding to the NSValue
rangeValuemethod, and in addition its elements must be sorted, non-overlapping, non-contiguous, and (except for the case of a single range) have non-zero-length. - replacementStrings:
The array of strings that will replace the characters in
affectedRanges, one string for each range;nilif only text attributes are being changed.
Return Value
true to allow the replacement, or false to reject the change.