NSTextView Class Reference
| Inherits from | |
| Conforms to | NSTextInput NSUserInterfaceValidations NSTextInputClient NSTextLayoutOrientationProvider NSDraggingSource NSChangeSpelling (NSText) NSIgnoreMisspelledWords (NSText) NSAnimatablePropertyContainer (NSView) NSUserInterfaceItemIdentification (NSView) NSDraggingDestination (NSView) NSCoding (NSResponder) NSObject (NSObject) |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in OS X v10.0 and later. |
| Declared in | NSTextView.h |
| Companion guides | |
Overview
The NSTextView class is the front-end class to the Application Kit’s text system. The class draws the text managed by the back-end components and handles user events to select and modify its text. NSTextView is the principal means to obtain a text object that caters to almost all needs for displaying and managing text at the user interface level. While NSTextView is a subclass of the NSText class—which declares the most general Cocoa interface to the text system—NSTextView adds major features beyond the capabilities of NSText.
Your applications will use the NSTextView class over the NSText class. It is also important to remember that NSTextView conforms to a large number of protocols as listed above. The methods of these protocols are available to instances of the NSTextView class.
Be sure to read Cocoa Text Architecture Guide and Text System User Interface Layer Programming Guide to fully understand how to use this class.
About Delegate Methods
The NSTextView class communicates with its delegate through methods declared both by the NSTextViewDelegate Protocol and by its superclass’s protocol, NSTextDelegate Protocol. All delegation messages come from the first text view.
Tasks
Initializing
Registering Services Information
Accessing Text System Objects
-
– setTextContainer: -
– replaceTextContainer: -
– textContainer -
– setTextContainerInset: -
– textContainerInset -
– textContainerOrigin -
– invalidateTextContainerOrigin -
– layoutManager -
– textStorage
Setting Graphics Attributes
-
– setBackgroundColor: -
– backgroundColor -
– setDrawsBackground: -
– drawsBackground -
– setAllowsDocumentBackgroundColorChange: -
– allowsDocumentBackgroundColorChange -
– changeDocumentBackgroundColor:
Controlling Display
-
– setNeedsDisplayInRect:avoidAdditionalLayout: -
– shouldDrawInsertionPoint -
– drawInsertionPointInRect:color:turnedOn: -
– drawViewBackgroundInRect: -
– setConstrainedFrameSize: -
– cleanUpAfterDragOperation -
– showFindIndicatorForRange:
Inserting Text
Setting Behavioral Attributes
-
– allowsUndo -
– setAllowsUndo: -
– setEditable: -
– isEditable -
– setSelectable: -
– isSelectable -
– setFieldEditor: -
– isFieldEditor -
– setRichText: -
– isRichText -
– setImportsGraphics: -
– importsGraphics -
– setBaseWritingDirection:range: -
– setDefaultParagraphStyle: -
– defaultParagraphStyle -
– outline: -
– allowsImageEditing -
– setAllowsImageEditing: -
– setAutomaticQuoteSubstitutionEnabled: -
– isAutomaticQuoteSubstitutionEnabled -
– toggleAutomaticQuoteSubstitution: -
– setAutomaticLinkDetectionEnabled: -
– isAutomaticLinkDetectionEnabled -
– toggleAutomaticLinkDetection: -
– displaysLinkToolTips -
– setDisplaysLinkToolTips: -
– toggleBaseWritingDirection:Deprecated in OS X v10.6
Using Text Formatting Controls
-
– setUsesRuler: -
– usesRuler -
– setRulerVisible: -
– isRulerVisible -
– setUsesInspectorBar: -
– usesInspectorBar
Managing the Selection
-
– selectedRanges -
– setSelectedRange: -
– setSelectedRanges: -
– setSelectedRange:affinity:stillSelecting: -
– setSelectedRanges:affinity:stillSelecting: -
– selectionAffinity -
– setSelectionGranularity: -
– selectionGranularity -
– setInsertionPointColor: -
– insertionPointColor -
– updateInsertionPointStateAndRestartTimer: -
– setSelectedTextAttributes: -
– selectedTextAttributes -
– setMarkedTextAttributes: -
– markedTextAttributes -
– setLinkTextAttributes: -
– linkTextAttributes -
– characterIndexForInsertionAtPoint:
Managing the Pasteboard
-
– preferredPasteboardTypeFromArray:restrictedToTypesFromArray: -
– readSelectionFromPasteboard: -
– readSelectionFromPasteboard:type: -
– readablePasteboardTypes -
– writablePasteboardTypes -
– writeSelectionToPasteboard:type: -
– writeSelectionToPasteboard:types: -
– validRequestorForSendType:returnType:
Setting Text Attributes
-
– alignJustified: -
– changeAttributes: -
– changeColor: -
– setAlignment:range: -
– setTypingAttributes: -
– typingAttributes -
– useStandardKerning: -
– lowerBaseline: -
– raiseBaseline: -
– turnOffKerning: -
– loosenKerning: -
– tightenKerning: -
– useStandardLigatures: -
– turnOffLigatures: -
– useAllLigatures: -
– toggleTraditionalCharacterShape:
Clicking and Pasting
Undo Support
Methods for Subclasses to Use or Override
-
– updateFontPanel -
– updateRuler -
– acceptableDragTypes -
– updateDragTypeRegistration -
– selectionRangeForProposedRange:granularity: -
– rangeForUserCharacterAttributeChange -
– rangesForUserCharacterAttributeChange -
– rangeForUserParagraphAttributeChange -
– rangesForUserParagraphAttributeChange -
– rangeForUserTextChange -
– rangesForUserTextChange -
– shouldChangeTextInRange:replacementString: -
– shouldChangeTextInRanges:replacementStrings: -
– didChangeText -
– setSmartInsertDeleteEnabled: -
– smartInsertDeleteEnabled -
– smartDeleteRangeForProposedRange: -
– smartInsertAfterStringForString:replacingRange: -
– smartInsertBeforeStringForString:replacingRange: -
– smartInsertForString:replacingRange:beforeString:afterString: -
– toggleSmartInsertDelete:
Working With the Spelling Checker
-
– isContinuousSpellCheckingEnabled -
– setContinuousSpellCheckingEnabled: -
– spellCheckerDocumentTag -
– toggleContinuousSpellChecking: -
– setGrammarCheckingEnabled: -
– isGrammarCheckingEnabled -
– toggleGrammarChecking: -
– setSpellingState:range:
Working with the Sharing Serice Picker
NSRulerView Client Methods
-
– rulerView:didMoveMarker: -
– rulerView:willMoveMarker:toLocation: -
– rulerView:shouldMoveMarker: -
– rulerView:didRemoveMarker: -
– rulerView:shouldRemoveMarker: -
– rulerView:didAddMarker: -
– rulerView:shouldAddMarker: -
– rulerView:willAddMarker:atLocation: -
– rulerView:handleMouseDown:
Assigning a Delegate
Dragging
-
– dragImageForSelectionWithEvent:origin: -
– dragOperationForDraggingInfo:type: -
– dragSelectionWithEvent:offset:slideBack: -
– acceptsGlyphInfo -
– setAcceptsGlyphInfo:
Speaking Text
Working with Panels
-
– setUsesFontPanel: -
– usesFontPanel -
– setUsesFindPanel: -
– usesFindPanel -
– performFindPanelAction: -
– orderFrontLinkPanel: -
– orderFrontListPanel: -
– orderFrontSpacingPanel: -
– orderFrontTablePanel: -
– orderFrontSubstitutionsPanel:
Text Completion
-
– complete: -
– completionsForPartialWordRange:indexOfSelectedItem: -
– insertCompletion:forPartialWordRange:movement:isFinal: -
– rangeForUserCompletion
Text Checking and Substitutions
-
– checkTextInDocument: -
– checkTextInSelection: -
– checkTextInRange:types:options: -
– handleTextCheckingResults:forRange:types:options:orthography:wordCount: -
– enabledTextCheckingTypes -
– setEnabledTextCheckingTypes: -
– isAutomaticDashSubstitutionEnabled -
– setAutomaticDashSubstitutionEnabled: -
– toggleAutomaticDashSubstitution: -
– isAutomaticDataDetectionEnabled -
– setAutomaticDataDetectionEnabled: -
– toggleAutomaticDataDetection: -
– isAutomaticSpellingCorrectionEnabled -
– setAutomaticSpellingCorrectionEnabled: -
– toggleAutomaticSpellingCorrection: -
– isAutomaticTextReplacementEnabled -
– setAutomaticTextReplacementEnabled: -
– toggleAutomaticTextReplacement:
Changing First Responder Status
-
– becomeFirstResponderAvailable in OS X v10.0 through OS X v10.4 -
– resignFirstResponderAvailable in OS X v10.0 through OS X v10.4
Supporting QuickLook
Changing Layout Orientation
Using the Find Bar
Class Methods
registerForServices
Registers send and return types for the Services facility.
Discussion
This method is invoked automatically when the first instance of a text view is created; you should never need to invoke it directly.
Subclasses of NSTextView that wish to add support for new service types should override registerForServices to call super and then register their own new types.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hInstance Methods
acceptableDragTypes
Returns the data types that the receiver accepts as the destination view of a dragging operation.
Return Value
The data types that the receiver accepts as the destination view of a dragging operation.
Discussion
These types are automatically registered as necessary by the text view. Subclasses should override this method as necessary to add their own types to those returned by NSTextView’s implementation. They must then also override the appropriate methods of the NSDraggingDestination protocol to support import of those types. See that protocol’s specification for more information.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hacceptsGlyphInfo
Returns whether the receiver accepts the glyph info attribute.
Return Value
YES if the receiver accepts the NSGlyphInfoAttributeName attribute from text input sources such as input methods and the pasteboard, NO otherwise.
Availability
- Available in OS X v10.2 and later.
See Also
Declared In
NSTextView.halignJustified:
Applies full justification to selected paragraphs (or all text, if the receiver is a plain text object).
Parameters
- sender
The control that sent the message; may be
nil.
Availability
- Available in OS X v10.0 and later.
See Also
-
alignCenter:(NSText) -
alignLeft:(NSText) -
alignRight:(NSText) -
alignment(NSText) -
setAlignment:(NSText)
Declared In
NSTextView.hallowedInputSourceLocales
Returns an array of locale identifiers representing input sources that are allowed to be enabled when the receiver has the keyboard focus.
Return Value
The locale identifiers of allowed input sources.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSTextView.hallowsDocumentBackgroundColorChange
Returns whether the receiver allows its background color to change.
Return Value
YES if the receiver allows its background color to change, otherwise NO.
Discussion
This corresponds to the background color of the entirety of the text view, not just to a selected range of text.
Availability
- Available in OS X v10.3 and later.
Declared In
NSTextView.hallowsImageEditing
Indicates whether image attachments should permit editing of their images.
Discussion
For image editing to be allowed, the text view must be editable and the text attachment cell must support image editing.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSTextView.hallowsUndo
Returns whether the receiver allows undo.
Return Value
YES if the receiver allows undo, otherwise NO.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hbackgroundColor
Returns the receiver’s background color.
Return Value
The receiver’s background color.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hbreakUndoCoalescing
Informs the receiver that it should begin coalescing successive typing operations in a new undo grouping.
Special Considerations
This method should be invoked when saving the receiver’s contents to preserve proper tracking of unsaved changes and the document’s dirty state.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTextView.hchangeAttributes:
Changes the attributes of the current selection.
Parameters
- sender
The control that sent the message. Must respond to
convertAttributes:.
Discussion
This method changes the attributes by invoking convertAttributes: on sender and applying the returned attributes to the appropriate text. See “Font Handling” in Cocoa Text Architecture Guide for more information on attribute conversion.
Availability
- Available in OS X v10.3 and later.
Declared In
NSTextView.hchangeColor:
Sets the color of the selected text.
Parameters
- sender
The control that sent the message.
NSTextView’s implementation sends acolormessage to sender to get the new color.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hchangeDocumentBackgroundColor:
An action method used to set the background color.
Parameters
- sender
The control that wants to set the background color.
Discussion
This method gets the new color by sending a color message to sender.
This will only set the background color if allowsDocumentBackgroundColorChangereturns YES.
Availability
- Available in OS X v10.3 and later.
Declared In
NSTextView.hchangeLayoutOrientation:
An action method that sets the layout orientation of the text.
Parameters
- sender
The sender.
Discussion
Calls setLayoutOrientation: with the sender's tag as the orientation.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTextView.hcharacterIndexForInsertionAtPoint:
Returns a character index appropriate for placing a zero-length selection for an insertion point associated with the mouse at the given point.
Parameters
- point
The point for which to return an index, in view coordinates.
Return Value
The character index for the insertion point.
Discussion
This method should be used for insertion points associated with mouse clicks, drag events, and so forth. For other purposes, it is better to use NSLayoutManager methods.
The NSTextInput method characterIndexForPoint: is not suitable for this role; it is intended only for uses related to text input methods.
Availability
- Available in OS X v10.5 and later.
Declared In
NSTextView.hcheckTextInDocument:
Performs the default text checking on the entire document.
Parameters
- sender
The control sending the message. May be
nil.
Discussion
Immediately performs the text checking and replaces the document content with the checked content.
The checks performed are specified by setEnabledTextCheckingTypes:;
Availability
- Available in OS X v10.6 and later.
Declared In
NSTextView.hcheckTextInRange:types:options:
Check and replace the text in the range using the specified checking types and options.
Parameters
- range
The range to check.
- checkingTypes
The type of checking to be performed, passed by-reference. The possible constants are listed in
NSTextCheckingTypesand can be combined using the C bit-wiseORoperator to perform multiple checks at the same time.- options
A dictionary of values used during the checking process to perform. See
Spell Checking Option Dictionary Keysfor the supported values.
Discussion
This method calls the delegate method textView:willCheckTextInRange:options:types: allowing you to modify the parameters before the checking occurs.
This method usually would not be called directly, since NSTextView itself will call it as needed, but it can be overridden.
Availability
- Available in OS X v10.6 and later.
Declared In
NSTextView.hcheckTextInSelection:
Performs the default text checking on the current selection.
Parameters
- sender
The control sending the message. May be
nil.
Discussion
Immediately performs the text checking and replaces the selection with the checked content.
The checks performed are specified by setEnabledTextCheckingTypes:;
Availability
- Available in OS X v10.6 and later.
Declared In
NSTextView.hcleanUpAfterDragOperation
Releases the drag information still existing after the dragging session has completed.
Discussion
Subclasses may override this method to clean up any additional data structures used for dragging. In your overridden method, be sure to invoke super’s implementation of this method.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hclickedOnLink:atIndex:
Causes the text view to act as if the user clicked on some text with the given link as the value of a link attribute associated with the text.
Parameters
- link
The link that was clicked; the value of
NSLinkAttributeName.- charIndex
The character index where the click occurred, indexed within the text storage.
Discussion
If, for instance, you have a special attachment cell that can follow links, you can use this method to ask the text view to follow a link once you decide it should. In addition, this method is invoked by the text view during mouse tracking if the user clicks a link.
The charIndex parameter is a character index somewhere in the range of the link attribute. If the user actually physically clicked the link, then it should be the character that was originally clicked. In some cases a link may be opened indirectly or programmatically, in which case a character index somewhere in the range of the link attribute is supplied.
This method sends the textView:clickedOnLink:atIndex: delegate message if the delegate implements it, so that the delegate can handle the click.
Availability
- Available in OS X v10.0 and later.
See Also
-
textView:clickedOnLink:atIndex:(NSTextViewDelegate)
Declared In
NSTextView.hcomplete:
Invokes completion in a text view.
Parameters
- sender
The control sending the message. May be
nil.
Discussion
By default invoked using the Escape key, this method provides users with a choice of completions for the word currently being typed. May be invoked programmatically if autocompletion is desired by a client of the text system. You can change the key invoking this method using the text system’s key bindings mechanism; see ““Text System Defaults and Key Bindings”" for an explanation of the procedure.
The delegate may replace or modify the list of possible completions by implementing textView:completions:forPartialWordRange:indexOfSelectedItem:. Subclasses can control the list by overriding completionsForPartialWordRange:indexOfSelectedItem:.
Availability
- Available in OS X v10.3 and later.
Declared In
NSTextView.hcompletionsForPartialWordRange:indexOfSelectedItem:
Returns an array of potential completions, in the order to be presented, representing possible word completions available from a partial word.
Parameters
- charRange
The range of characters of the matched partial word to be completed.
- index
On return, optionally set to the completion that should be initially selected. The default is 0, and –1 indicates no selection.
Return Value
An array of potential completions, in the order to be presented, representing possible word completions available from a partial word at charRange. Returning nil or a zero-length array suppresses completion.
Discussion
May be overridden by subclasses to modify or override the list of possible completions.
This method should call the delegate method textView:completions:forPartialWordRange:indexOfSelectedItem: if the delegate implements such a method.
Availability
- Available in OS X v10.3 and later.
Declared In
NSTextView.hdefaultParagraphStyle
Returns the receiver’s default paragraph style.
Return Value
The receiver's default paragraph style.
Availability
- Available in OS X v10.3 and later.
See Also
Declared In
NSTextView.hdelegate
Returns the delegate used by the receiver and all other text views sharing the receiver’s layout manager.
Return Value
The delegate used by the receiver and all other text views sharing the receiver’s layout manager, or nil if there is none.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hdidChangeText
Sends out necessary notifications when a text change completes.
Discussion
Invoked automatically at the end of a series of changes, this method posts an NSTextDidChangeNotification to the default notification center, which also results in the delegate receiving an NSText delegate textDidChange: message.
Subclasses implementing methods that change their text should invoke this method at the end of those methods. See “Subclassing NSTextView” in Cocoa Text Architecture Guide for more information.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hdisplaysLinkToolTips
Indicates whether the text view automatically supplies the destination of a link as a tooltip for text that has a link attribute.
Discussion
The default value for this feature is YES; clients who do not wish tooltips to be displayed automatically must explicitly disable it.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSTextView.hdragImageForSelectionWithEvent:origin:
Returns an appropriate drag image for the drag initiated by the specified event.
Parameters
- event
The event that initiated the drag session.
- origin
On return, the lower-left point of the image in view coordinates.
Return Value
An appropriate drag image for the drag initiated by event. May be nil, in which case a default icon will be used.
Discussion
This method is used by dragSelectionWithEvent:offset:slideBack:. It can be called by others who need such an image, or can be overridden by subclasses to return a different image.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hdragOperationForDraggingInfo:type:
Returns the type of drag operation that should be performed if the image were released now.
Parameters
- dragInfo
The drag information.
- type
The pasteboard type that will be read from the dragging pasteboard.
Return Value
The drag operation that should be performed if the image were released now.
Discussion
The returned value should be one of the following:
Option | Meaning |
|---|---|
The data represented by the image will be copied. | |
The data will be shared. | |
The operation will be defined by the destination. | |
The operation is negotiated privately between the source and the destination. |
If none of the operations is appropriate, this method should return NSDragOperationNone.
This method is called repeatedly from draggingEntered: and draggingUpdated: as the user drags the image.
Availability
- Available in OS X v10.0 and later.
See Also
-
draggingEntered:(NSDraggingDestination) -
draggingUpdated:(NSDraggingDestination)
Declared In
NSTextView.hdragSelectionWithEvent:offset:slideBack:
Begins dragging the current selected text range.
Parameters
- event
The event that initiated dragging the selection.
- mouseOffset
The cursor’s current location relative to the mouse-down event.
- slideBack
YESif the image being dragged should slide back to its original position if the drag does not succeed,NOotherwise.
Return Value
YES if the drag can be successfully initiated, NO otherwise.
Discussion
Primarily for subclasses, who can override it to intervene at the beginning of a drag.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hdrawInsertionPointInRect:color:turnedOn:
Draws or erases the insertion point.
Parameters
- aRect
The rectangle in which to draw the insertion point.
- aColor
The color with which to draw the insertion point.
- flag
YESto draw the insertion point,NOto erase it.
Special Considerations
The focus must be locked on the receiver when this method is invoked. You should not need to invoke this method directly.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hdrawsBackground
Returns whether the receiver draws its background
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hdrawViewBackgroundInRect:
Draws the background of the text view.
Parameters
- rect
The rectangle in which to draw the background.
Discussion
Subclasses can override this method to perform additional drawing behind the text.
Availability
- Available in OS X v10.3 and later.
Declared In
NSTextView.henabledTextCheckingTypes
Returns the default text checking types.
Return Value
The currently enabled default text checking types
Availability
- Available in OS X v10.6 and later.
See Also
Declared In
NSTextView.hhandleTextCheckingResults:forRange:types:options:orthography:wordCount:
Handles the text checking results returned by the text view
Parameters
- results
An array of
NSTextCheckingResultobjects.- range
The range of text that was checked.
- checkingTypes
The type of checking performed. The possible constants are listed in
NSTextCheckingTypesand can be combined using the C bit-wiseORoperator to perform multiple checks at the same time.- options
The dictionary of values used during the checking process to perform. See
Spell Checking Option Dictionary Keysfor the supported values.- orthography
The orthography of the checked text.
- wordCount
The number of words.
Discussion
The NSTextViewDelegate Protocol offers a method, textView:didCheckTextInRange:types:options:results:orthography:wordCount: that is called after the checking is performed, allowing you to modify the results.
This method usually would not be called directly, since NSTextView itself will call it as needed, but it can be overridden.
Availability
- Available in OS X v10.6 and later.
Declared In
NSTextView.himportsGraphics
Returns whether the text views sharing the receiver’s layout manager allow the user to import files by dragging.
Return Value
YES if the user is allowed to import files by dragging onto the text views sharing the receiver’s layout manager, NO otherwise.
Discussion
Text views that are set to accept dragged files are also set to allow rich text. By default, text views don’t accept dragged files but do allow rich text.
Availability
- Available in OS X v10.0 and later.
See Also
-
– isRichText -
– textStorage -
attributedStringWithAttachment:(NSAttributedString Additions) -
insertAttributedString:atIndex:(NSMutableAttributedString) -
– setImportsGraphics:
Declared In
NSTextView.hinitWithFrame:
Initializes a text view.
Parameters
- frameRect
The frame rectangle of the text view.
Return Value
An initialized text view.
Discussion
This method creates the entire collection of objects associated with a text view—its text container, layout manager, and text storage—and invokes initWithFrame:textContainer:.
This method creates the text web in such a manner that the text view is the principal owner of the objects in the web.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hinitWithFrame:textContainer:
Initializes a text view.
Parameters
- frameRect
The frame rectangle of the text view.
- aTextContainer
The text container of the text view.
Return Value
An initialized text view.
Discussion
This method is the designated initializer for NSTextView objects.
Unlike initWithFrame:, which builds up an entire group of text-handling objects, you use this method after you’ve created the other components of the text-handling system—a text storage object, a layout manager, and a text container. Assembling the components in this fashion means that the text storage, not the text view, is the principal owner of the component objects.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hinsertCompletion:forPartialWordRange:movement:isFinal:
Inserts the selected completion into the text at the appropriate location.
Parameters
- word
The text to insert, including the matched partial word and its potential completion.
- charRange
The range of characters of the matched partial word to be completed.
- movement
The direction of movement. For possible values see the
NSTextConstants section. This value allows subclasses to distinguish between canceling completion and selection by arrow keys, by return, by tab, or by other means such as clicking.- flag
NOwhile the user navigates through the potential text completions,YESwhen a completion is definitively selected or cancelled and the original value is reinserted.
Discussion
This method has two effects, text substitution and changing of the selection:
It replaces the text between
charRange.startand the current insertion point with word.If flag is
NOit changes the selection to be the last n characters of word where n is equal to[word length]minuscharRange.length, that is, the potential completion.If flag is
YESit makes the selection empty and puts the insertion point just after word.
Availability
- Available in OS X v10.3 and later.
Declared In
NSTextView.hinsertionPointColor
Returns the color used to draw the insertion point.
Return Value
The color used to draw the insertion point.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hinsertText:
Inserts aString into the receiver’s text at the insertion point if there is one, otherwise replacing the selection.
Parameters
- aString
The string to insert. aString can be either an
NSStringobject or anNSAttributedStringobject.
Discussion
The inserted text is assigned the current typing attributes.
This method is the means by which text typed by the user enters an NSTextView. See the NSInputManager class and NSTextInput protocol specifications for more information.
This method is the entry point for inserting text typed by the user and is generally not suitable for other purposes. Programmatic modification of the text is best done by operating on the text storage directly. Because this method pertains to the actions of the user, the text view must be editable for the insertion to work.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hinvalidateTextContainerOrigin
Invalidates the calculated origin of the text container.
Discussion
This method is invoked automatically; you should never need to invoke it directly. Usually called because the text view has been resized or the contents of the text container have changed.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hisAutomaticDashSubstitutionEnabled
Returns whether automatic dash substitution is enabled.
Return Value
YES if it is enabled, otherwise NO.
Discussion
Turning on automatic dash substitution enables automatic conversion of a two ASCII hyphen (-) characters into an em-dash.
Availability
- Available in OS X v10.6 and later.
Declared In
NSTextView.hisAutomaticDataDetectionEnabled
Returns whether automatic data detection is enabled.
Return Value
YES if it is enabled, otherwise NO.
Discussion
Automatic data detection enables detection of dates, addresses, and phone numbers.
Availability
- Available in OS X v10.6 and later.
Declared In
NSTextView.hisAutomaticLinkDetectionEnabled
Indicates whether automatic link detection is enabled.
Discussion
Automatic link detection causes strings representing URLs typed in the view to be automatically made into links to those URLs.
Availability
- Available in OS X v10.5 and later.
See Also
-
– setAutomaticLinkDetectionEnabled: -
– toggleAutomaticLinkDetection: -
URLAtIndex:effectiveRange:(NSAttributedString)
Declared In
NSTextView.hisAutomaticQuoteSubstitutionEnabled
Indicates whether automatic quotation mark substitution is enabled.
Discussion
Automatic quote substitution causes ASCII quotation marks and apostrophes to be automatically replaced, on a context-dependent basis, with more typographically accurate symbols.
Availability
- Available in OS X v10.5 and later.
Declared In
NSTextView.hisAutomaticSpellingCorrectionEnabled
Returns whether automatic spelling correction is enabled.
Return Value
YES if it is enabled, otherwise NO.
Availability
- Available in OS X v10.6 and later.
Declared In
NSTextView.hisAutomaticTextReplacementEnabled
Returns whether automatic text replacement is enabled.
Return Value
YES if it is enabled, otherwise NO.
Discussion
Turning on automatic text replacement enables automatic substitution of a variety of static text items based on user preferences.
Availability
- Available in OS X v10.6 and later.
Declared In
NSTextView.hisCoalescingUndo
Returns whether undo coalescing is in progress.
Return Value
YES if undo coalescing is in progress, otherwise NO.
Availability
- Available in OS X v10.6 and later.
See Also
Declared In
NSTextView.hisContinuousSpellCheckingEnabled
Indicates whether the receiver has continuous spell checking enabled.
Return Value
YES if the receiver has continuous spell checking enabled, otherwise,NO.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hisEditable
Returns whether the text views sharing the receiver’s layout manager allow the user to edit text.
Return Value
YES if the text views sharing the receiver’s layout manager allow the user to edit text, NO otherwise.
Discussion
If a text view is editable, it’s also selectable.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hisFieldEditor
Returns whether the text views sharing the receiver’s layout manager behave as field editors.
Return Value
YES if the text views sharing the receiver’s layout manager behave as field editors, NO otherwise.
Discussion
Field editors interpret Tab, Shift-Tab, and Return (Enter) as cues to end editing and possibly to change the first responder. Non-field editors instead accept these characters as text input. See “Text Fields, Text Views, and the Field Editor” for more information on field editors. By default, text views don’t behave as field editors.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hisGrammarCheckingEnabled
Indicates whether or not grammar checking is enabled.
Discussion
If grammar checking is enabled, then it is performed alongside spell checking, whenever the text view checks spelling, whether continuously or manually.
Availability
- Available in OS X v10.5 and later.
Declared In
NSTextView.hisIncrementalSearchingEnabled
Returns whether incremental searching is enabled.
Return Value
YES if incremental searching is enabled; otherwise NO.
Discussion
See NSTextFinder Class Reference for information about the find bar.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTextView.hisRichText
Returns whether the text views sharing the receiver’s layout manager allow the user to apply attributes to specific ranges of text.
Return Value
YES if the user is allowed to apply attributes to specific ranges of text in text views sharing the receiver’s layout manager, NO otherwise.
Discussion
Text fields that don't allow rich text also don't accept dragged files. By default, text views let the user apply multiple attributes to text, but don’t accept dragged files.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hisRulerVisible
Returns whether the scroll view enclosing the text views sharing the receiver’s layout manager shows its ruler.
Return Value
YES if the scroll view enclosing the text views sharing the receiver’s layout manager shows its ruler, NO otherwise. The default is NO.
Availability
- Available in OS X v10.0 and later.
See Also
-
– usesRuler -
– setRulerVisible: -
toggleRuler:(NSText)
Declared In
NSTextView.hisSelectable
Returns whether the text views sharing the receiver’s layout manager allow the user to select text.
Return Value
YES if the user is allowed to select text of all text views sharing the receiver's layout manager, NO otherwise.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hlayoutManager
Returns the layout manager that lays out text for the receiver’s text container.
Return Value
The layout manager that lays out text for the receiver’s text container, or nil if there’s no such object, such as when a text view isn’t linked into a group of text objects.
Availability
- Available in OS X v10.0 and later.
See Also
-
– textContainer -
setLayoutManager:(NSTextContainer) -
replaceLayoutManager:(NSTextContainer)
Declared In
NSTextView.hlinkTextAttributes
Returns the attributes used to draw the onscreen presentation of link text.
Return Value
A dictionary of attributes corresponding to the onscreen presentation of link text.
Discussion
Link text attributes are applied as temporary attributes to any text with a link attribute. Candidates include those attributes that do not affect layout.
In applications created prior to OS X v10.3, the default value is an empty dictionary. In applications created with OS X v10.3 or greater, the default attributes specify blue text with a single underline and the pointing hand cursor.
Availability
- Available in OS X v10.3 and later.
See Also
Declared In
NSTextView.hloosenKerning:
Increases the space between glyphs in the receiver’s selection, or in all text if the receiver is a plain text view.
Parameters
- sender
The control that sent the message; may be
nil.
Discussion
Kerning values are determined by the point size of the fonts in the selection.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hlowerBaseline:
Lowers the baseline offset of selected text by 1 point, or of all text if the receiver is a plain text view.
Parameters
- sender
The control that sent the message; may be
nil.
Discussion
As such, this method defines a more primitive operation than subscripting.
Availability
- Available in OS X v10.0 and later.
See Also
-
– raiseBaseline: -
subscript:(NSText) -
unscript:(NSText)
Declared In
NSTextView.hmarkedTextAttributes
Returns the attributes used to draw marked text.
Return Value
A dictionary of attributes used to draw marked text. Text color, background color, and underline are the only supported attributes for marked text.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.horderFrontLinkPanel:
Brings forward a panel allowing the user to manipulate links in the text view.
Parameters
- sender
The control sending the message. May be
nil.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTextView.horderFrontListPanel:
Brings forward a panel allowing the user to manipulate text lists in the text view.
Parameters
- sender
The control sending the message. May be
nil.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTextView.horderFrontSharingServicePicker:
Creates and displays a new instance of the the sharing service picker.
Parameters
- sender
The sender.
Discussion
Creates a new instance of NSSharingServicePicker based on the current selection & shows to the screen. The items passed to the NSSharingServicePicker initializer are determined using the delegate method textView:willShowSharingServicePicker:forItems:.
When the current selection is 0 length, the whole document is passed to the method.
Availability
- Available in OS X v10.8 and later.
Declared In
NSTextView.horderFrontSpacingPanel:
Brings forward a panel allowing the user to manipulate text line heights, interline spacing, and paragraph spacing, in the text view.
Parameters
- sender
The control sending the message. May be
nil.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTextView.horderFrontSubstitutionsPanel:
Brings forward a panel allowing the user to specify string substitutions in the text view.
Parameters
- sender
The control sending the message. May be
nil.
Availability
- Available in OS X v10.6 and later.
Declared In
NSTextView.horderFrontTablePanel:
Brings forward a panel allowing the user to manipulate text tables in the text view.
Parameters
- sender
The control sending the message. May be
nil.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTextView.houtline:
Adds the outline attribute to the selected text attributes if absent; removes the attribute if present.
Parameters
- sender
The control that sent the message; may be
nil.
Discussion
If there is a selection and the first character of the selected range has a non-zero stroke width, or if there is no selection and the typing attributes have a non-zero stroke width, then the stroke width is removed; otherwise the value of NSStrokeWidthAttributeName is set to the default value for outline (3.0).
Operates on the selected range if the receiver contains rich text. For plain text the range is the entire contents of the receiver.
Availability
- Available in OS X v10.3 and later.
Declared In
NSTextView.hpasteAsPlainText:
Inserts the contents of the pasteboard into the receiver’s text as plain text.
Parameters
- sender
The control that sent the message; may be
nil.
Discussion
This method behaves analogously to insertText:.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hpasteAsRichText:
This action method inserts the contents of the pasteboard into the receiver’s text as rich text, maintaining its attributes.
Parameters
- sender
The control that sent the message; may be
nil.
Discussion
The text is inserted at the insertion point if there is one, otherwise replacing the selection.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hperformFindPanelAction:
Performs a find panel action specified by the sender's tag.
Parameters
- sender
The control sending the message. This method sends the
tagmethod to determine what operation to perform. The list of possible tags is provided in “Constants.”
Discussion
This is the generic action method for the find menu and find panel, and can be overridden to implement a custom find panel.
Availability
- Available in OS X v10.3 and later.
Declared In
NSTextView.hpreferredPasteboardTypeFromArray:restrictedToTypesFromArray:
Returns whatever type on the pasteboard would be most preferred for copying data.
Parameters
- availableTypes
The types currently available on the pasteboard.
- allowedTypes
Types allowed in the return value. If
nil, any available type is allowed.
Return Value
The preferred type to provide given the available types and the allowed types.
Discussion
You should not need to override this method. You should also not need to invoke it unless you are implementing a new type of pasteboard to handle services other than copy/paste or dragging.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hquickLookPreviewableItemsInRanges:
Returns an array of URLs for items that can be displayed by QuickLook in the specified ranges.
Parameters
- ranges
An array of ranges.
Return Value
Returns an array of document URLs for text attachment content, if available.
Discussion
Each preview item must conform to the QLPreviewItem protocol.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTextView.hraiseBaseline:
Raises the baseline offset of selected text by 1 point, or of all text if the receiver is a plain text view.
Parameters
- sender
The control that sent the message; may be
nil.
Discussion
As such, this method defines a more primitive operation than superscripting.
Availability
- Available in OS X v10.0 and later.
See Also
-
– lowerBaseline: -
superscript:(NSText) -
unscript:(NSText)
Declared In
NSTextView.hrangeForUserCharacterAttributeChange
Returns the range of characters affected by an action method that changes character (not paragraph) attributes.
Return Value
The range of characters affected by an action method that changes character (not paragraph) attributes, such as the NSText action method changeFont:. For rich text this range is typically the range of the selection. For plain text this range is the entire contents of the receiver. If the receiver isn’t editable or doesn’t use the Font panel, the range returned has a location of NSNotFound.
Special Considerations
In OS X v10.4 and later, returns the first subrange where there is a multiple-range selection.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hrangeForUserCompletion
Returns the partial range from the most recent beginning of a word up to the insertion point.
Return Value
The partial range from the most recent beginning of a word up to the insertion point. Returning (NSNotFound, 0) suppresses completion.
Discussion
May be overridden by subclasses to alter the range to be completed.
The return value from this method is intended to be used for the range argument in the text completion methods such as completionsForPartialWordRange:indexOfSelectedItem:.
Special Considerations
In OS X version 10.4 and later, if there are multiple selections, this method acts on the first selected subrange.
Availability
- Available in OS X v10.3 and later.
Declared In
NSTextView.hrangeForUserParagraphAttributeChange
Returns the range of characters affected by an action method that changes paragraph (not character) attributes.
Return Value
The range of characters affected by an action method that changes paragraph (not character) attributes, such as the NSText action method alignLeft:. For rich text this range is typically calculated by extending the range of the selection to paragraph boundaries. For plain text this range is the entire contents of the receiver. If the receiver isn’t editable or doesn’t use the Font panel, the range returned has a location of NSNotFound.
Special Considerations
In OS X version 10.4 and later, if there are multiple selections, this method acts on the first selected subrange.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hrangeForUserTextChange
Returns the range of characters affected by a method that changes characters (as opposed to attributes).
Return Value
The range of characters affected by a method that changes characters (as opposed to attributes), such as insertText:. This is typically the range of the selection. If the receiver isn’t editable the range returned has a location of NSNotFound.
Special Considerations
In OS X version 10.4 and later, if there are multiple selections, this method acts on the first selected subrange.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hrangesForUserCharacterAttributeChange
Returns an array containing the ranges of characters affected by an action method that changes character (not paragraph) attributes.
Return Value
An array containing the ranges of characters affected by an action method that changes character (not paragraph) attributes, such as the NSText action method changeFont:. For rich text these ranges are typically the ranges of the selections. For plain text the range is the entire contents of the receiver. Returns nil if the receiver isn’t editable or doesn’t use the Font panel.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTextView.hrangesForUserParagraphAttributeChange
Returns an array containing the ranges of characters affected by a method that changes paragraph (not character) attributes.
Return Value
An array containing the ranges of characters affected by an action method that changes paragraph (not character) attributes, such as the NSText action method alignLeft:. For rich text these ranges are typically calculated by extending the range of the selection to paragraph boundaries. For plain text the range is the entire contents of the receiver. Returns nil if the receiver isn’t editable or doesn’t use the Font panel.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTextView.hrangesForUserTextChange
Returns an array containing the ranges of characters affected by a method that changes characters (as opposed to attributes).
Return Value
An array containing the ranges of characters affected by a method that changes characters (as opposed to attributes), such as insertText:. These are typically the ranges of the selections. Returns nil if the receiver isn’t editable.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTextView.hreadablePasteboardTypes
Returns the types this text view can read immediately from the pasteboard.
Return Value
An array of strings describing the types this text view can read immediately from the pasteboard. The strings are ordered by the default preferences.
Discussion
You can override this method to provide support for new types of data. If you want to add support for the default types, you can invoke the superclass version of this method or add the types directly in your overridden version.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hreadSelectionFromPasteboard:
Reads the text view’s preferred type of data from the specified pasteboard.
Parameters
- pboard
The pasteboard to read from.
Return Value
YES if the data was successfully read, NO otherwise.
Discussion
This method invokes the preferredPasteboardTypeFromArray:restrictedToTypesFromArray: method to determine the text view’s preferred type of data and then reads the data using the readSelectionFromPasteboard:type: method.
You should not need to override this method. You might need to invoke this method if you are implementing a new type of pasteboard to handle services other than copy/paste or dragging.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hreadSelectionFromPasteboard:type:
Reads data of the given type from the specified pasteboard.
Parameters
- pboard
The pasteboard to read from.
- type
The type of data to read.
Return Value
YES if the data was successfully read, NO otherwise.
Discussion
The new data is placed at the current insertion point, replacing the current selection if one exists.
You should override this method to read pasteboard types other than the default types. Use the rangeForUserTextChange method to obtain the range of characters (if any) to be replaced by the new data.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hreplaceTextContainer:
Replaces the text container for the group of text system objects containing the receiver, keeping the association between the receiver and its layout manager intact.
Parameters
- aTextContainer
The new text container. This method raises
NSInvalidArgumentExceptionif aTextContainer isnil.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hrulerView:didAddMarker:
Modifies the paragraph style of the paragraphs containing the selection to accommodate a new marker.
Parameters
- aRulerView
The ruler view sending the message.
- aMarker
The marker that was added.
Discussion
This method records the change by invoking didChangeText after adding the marker.
NSTextView checks for permission to make the change in its rulerView:shouldAddMarker: method, which invokes shouldChangeTextInRange:replacementString: to send out the proper request and notifications, and only invokes this method if permission is granted.
Availability
- Available in OS X v10.0 and later.
See Also
-
representedObject(NSRulerMarker) -
– rulerView:didMoveMarker: -
– rulerView:didRemoveMarker:
Declared In
NSTextView.hrulerView:didMoveMarker:
Modifies the paragraph style of the paragraphs containing the selection to record the new location of the marker.
Parameters
- aRulerView
The ruler view sending the message.
- aMarker
The marker that was moved.
Discussion
This method records the change by invoking didChangeText after moving the marker.
NSTextView checks for permission to make the change in its rulerView:shouldMoveMarker: method, which invokes shouldChangeTextInRange:replacementString: to send out the proper request and notifications, and only invokes this method if permission is granted.
Availability
- Available in OS X v10.0 and later.
See Also
-
representedObject(NSRulerMarker) -
– rulerView:didAddMarker: -
– rulerView:didRemoveMarker:
Declared In
NSTextView.hrulerView:didRemoveMarker:
Modifies the paragraph style of the paragraphs containing the selection—if possible—by removing the specified marker.
Parameters
- aRulerView
The ruler view sending the message.
- aMarker
The marker that was removed.
Discussion
This method records the change by invoking didChangeText after removing the marker.
NSTextView checks for permission to move or remove a tab stop in its rulerView:shouldMoveMarker: method, which invokes shouldChangeTextInRange:replacementString: to send out the proper request and notifications, and only invokes this method if permission is granted.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hrulerView:handleMouseDown:
Adds a left tab marker to the ruler at the location clicked.
Parameters
- aRulerView
The ruler view sending the message.
- theEvent
The mouse down event.
Discussion
A subclass can override this method to provide other behavior, such as creating guidelines. This method is invoked once with theEvent when the user first clicks the ruler area of aRulerView, as described in the NSRulerView class specification.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hrulerView:shouldAddMarker:
Returns whether a new marker can be added.
Parameters
- aRulerView
The ruler view sending the message.
- aMarker
The marker to be added.
Return Value
YES if aMarker can be added, NO otherwise.
Discussion
The receiver checks for permission to make the change by invoking shouldChangeTextInRange:replacementString: and returning the return value of that message. If the change is allowed, the receiver is then sent a rulerView:didAddMarker: message.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hrulerView:shouldMoveMarker:
Returns whether the marker should be moved.
Parameters
- aRulerView
The ruler view sending the message.
- aMarker
The marker to be moved.
Return Value
YES if aMarker can be moved, NO otherwise.
Discussion
This method controls whether an existing marker aMarker can be moved. The receiver checks for permission to make the change by invoking shouldChangeTextInRange:replacementString: and returning the return value of that message. If the change is allowed, the receiver is then sent a rulerView:didMoveMarker: message.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hrulerView:shouldRemoveMarker:
Returns whether the marker should be removed.
Parameters
- aRulerView
The ruler view sending the message.
- aMarker
The marker to be removed.
Return Value
YES if aMarker can be removed, NO otherwise.
Discussion
Only markers that represent tab stops can be removed. This method returns YES if aMarker represents an NSTextTab object, NO otherwise. Because this method can be invoked repeatedly as the user drags a ruler marker, it returns that value immediately. If the change is allowed and the user actually removes the marker, the receiver is also sent a rulerView:didRemoveMarker: message.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hrulerView:willAddMarker:atLocation:
Returns a potentially modified location to which the marker should be added.
Parameters
- aRulerView
The ruler view sending the message.
- aMarker
The marker to be added.
- location
The new location for the marker, in the ruler view’s coordinates.
Return Value
The modified location to which the marker should be added.
Discussion
This method ensures that the proposed location of aMarker lies within the appropriate bounds for the receiver’s text container, returning the modified location. Appropriate bounds are those of the text container minus its line fragment padding.
Typically, the ruler view's width matches that of its text view.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hrulerView:willMoveMarker:toLocation:
Returns a potentially modified location to which the marker should be moved.
Parameters
- aRulerView
The ruler view sending the message.
- aMarker
The marker to be moved.
- location
The new location for the marker, in the ruler view’s coordinates.
Return Value
The modified location to which the marker should be moved.
Discussion
This method ensures that the proposed location of aMarker lies within the appropriate bounds for the receiver’s text container. Appropriate bounds are those of the text container minus its line fragment padding.
Typically, the ruler view's width matches that of its text view.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hselectedRanges
Returns an array containing the ranges of characters selected in the receiver’s layout manager.
Return Value
A non-nil, non-empty array of objects responding to the NSValue rangeValue method. In addition, the objects in the array are sorted, non-overlapping, non-contiguous, and (except for the case of a single range) have non-zero-length.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTextView.hselectedTextAttributes
Returns the attributes used to indicate the selection.
Return Value
A dictionary of attributes used to indicate the selection. Text color, background color, and underline are the only supported attributes for selected text. Typically only the text background color is used.
Availability
- Available in OS X v10.0 and later.
See Also
-
selectedRange(NSTextInput) -
– setSelectedTextAttributes:
Declared In
NSTextView.hselectionAffinity
Returns the preferred direction of selection.
Return Value
The preferred direction of selection.
Discussion
Selection affinity determines whether, for example, the insertion point appears after the last character on a line or before the first character on the following line in cases where text wraps across line boundaries.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hselectionGranularity
Returns the current selection granularity, used during mouse tracking to modify the range of the selection.
Return Value
The current selection granularity.
Discussion
See setSelectionGranularity: for a discussion of how selection granularity affects the behavior of selection extension.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hselectionRangeForProposedRange:granularity:
Returns an adjusted selected range based on the selection granularity.
Parameters
- proposedSelRange
The proposed selected range.
- granularity
The selection granularity.
Return Value
The adjusted selected range, taking into account the selection granularity.
Discussion
This method is invoked repeatedly during mouse tracking to modify the range of the selection. Override this method to specialize selection behavior.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hsetAcceptsGlyphInfo:
Sets whether the receiver accepts the glyph info attribute.
Parameters
- flag
YESif the receiver should accept theNSGlyphInfoAttributeNameattribute from text input sources such as input methods and the pasteboard,NOotherwise.
Availability
- Available in OS X v10.2 and later.
See Also
Declared In
NSTextView.hsetAlignment:range:
Sets the alignment of the paragraphs containing characters in the specified range.
Parameters
- alignment
The new alignment.
- aRange
The range of characters whose paragraphs will have their alignment set.
Discussion
This method does not include undo support by default. Clients must invoke shouldChangeTextInRanges:replacementStrings: or shouldChangeTextInRange:replacementString: to include this method in an undoable action.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hsetAllowedInputSourceLocales:
Sets an array of locale identifiers representing input sources that are allowed to be enabled when the receiver has the keyboard focus.
Parameters
- localeIdentifiers
The new locale identifiers of allowed input sources.
Discussion
You can use the meta-locale identifier, NSAllRomanInputSourcesLocaleIdentifier, to specify input sources that are limited for Roman script editing.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSTextView.hsetAllowsDocumentBackgroundColorChange:
Sets whether the receiver allows its background color to change.
Parameters
- flag
YESif the receiver allows the background color to change, otherwiseNO.
Discussion
This corresponds to the background color of the entirety of the text view, not just to a selected range of text.
Availability
- Available in OS X v10.3 and later.
Declared In
NSTextView.hsetAllowsImageEditing:
Specifies whether image attachments should permit editing of their images.
Discussion
For image editing to be allowed, the text view must be editable and the text attachment cell must support image editing.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSTextView.hsetAllowsUndo:
Sets whether undo support is enabled.
Parameters
- flag
YESto enable undo support,NOotherwise.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hsetAutomaticDashSubstitutionEnabled:
Sets whether automatic dash substitution is enabled.
Parameters
- flag
YESif it should be enabled, otherwiseNO.
Discussion
Turning on automatic dash substitution enables automatic conversion of sequences of ASCII hyphen (-) characters to typographic dashes.
Availability
- Available in OS X v10.6 and later.
Declared In
NSTextView.hsetAutomaticDataDetectionEnabled:
Sets whether automatic data detection is enabled.
Parameters
- flag
YESif it should be enabled, otherwiseNO.
Discussion
Automatic data detection enables detection of dates, addresses, and phone numbers.
Availability
- Available in OS X v10.6 and later.
Declared In
NSTextView.hsetAutomaticLinkDetectionEnabled:
Enables or disables automatic link detection.
Discussion
Automatic link detection causes strings representing URLs typed in the view to be automatically made into links to those URLs.
Availability
- Available in OS X v10.5 and later.
See Also
-
– isAutomaticLinkDetectionEnabled -
– toggleAutomaticLinkDetection: -
URLAtIndex:effectiveRange:(NSAttributedString)
Declared In
NSTextView.hsetAutomaticQuoteSubstitutionEnabled:
Enables and disables automatic quotation mark substitution.
Discussion
Automatic quote substitution causes ASCII quotation marks and apostrophes to be automatically replaced, on a context-dependent basis, with more typographically accurate symbols.
Availability
- Available in OS X v10.5 and later.
Declared In
NSTextView.hsetAutomaticSpellingCorrectionEnabled:
Sets whether automatic spelling correction is enabled.
Parameters
- flag
YESif it should be enabled, otherwiseNO.
Availability
- Available in OS X v10.6 and later.
Declared In
NSTextView.hsetAutomaticTextReplacementEnabled:
Sets whether automatic text replacement is enabled.
Parameters
- flag
YESif it should be enabled, otherwiseNO.
Discussion
Turning on automatic text replacement enables automatic substitution of a variety of static text items based on user preferences.
Availability
- Available in OS X v10.6 and later.
Declared In
NSTextView.hsetBackgroundColor:
Sets the receiver’s background color.
Parameters
- aColor
The new background color.
Special Considerations
This method does not include undo support by default. Clients must invoke shouldChangeTextInRanges:replacementStrings: or shouldChangeTextInRange:replacementString: to include this method in an undoable action.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hsetBaseWritingDirection:range:
Sets the base writing direction of a range of text.
Parameters
- writingDirection
The new writing direction for the text in range.
- range
The range of text that will have the new writing direction.
Discussion
Invoke this method to change the base writing direction from left-to-right to right-to-left for languages like Hebrew and Arabic, for example.
This method does not include undo support by default. Clients must invoke shouldChangeTextInRanges:replacementStrings: or shouldChangeTextInRange:replacementString: to include this method in an undoable action.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTextView.hsetConstrainedFrameSize:
Attempts to set the frame size as if by user action.
Parameters
- desiredSize
The new desired size.
Discussion
This method respects the receiver’s existing minimum and maximum sizes and by whether resizing is permitted.
Availability
- Available in OS X v10.0 and later.
See Also
-
minSize(NSText) -
maxSize(NSText) -
isHorizontallyResizable(NSText) -
isVerticallyResizable(NSText)
Declared In
NSTextView.hsetContinuousSpellCheckingEnabled:
Enables or disables continuous spell checking.
Parameters
- flag
If
YES, enables continuous spell checking; ifNO, disables it.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hsetDefaultParagraphStyle:
Sets the receiver’s default paragraph style.
Parameters
- paragraphStyle
The new default paragraph style.
Availability
- Available in OS X v10.3 and later.
See Also
Declared In
NSTextView.hsetDelegate:
Sets the delegate for all text views sharing the receiver’s layout manager.
Parameters
- anObject
The new delegate object.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hsetDisplaysLinkToolTips:
Enables or disables automatic display of link tooltips.
Discussion
The default value for this feature is YES; clients who do not wish tooltips to be displayed automatically must explicitly disable it.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSTextView.hsetDrawsBackground:
Sets whether the receiver draws its background.
Parameters
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hsetEditable:
Controls whether the text views sharing the receiver’s layout manager allow the user to edit text.
Parameters
- flag
YESto allow the user to edit text and attributes of all text views sharing the receiver's layout manager,NOotherwise.
Discussion
If a text view is made editable, it’s also made selectable. Text views are editable by default.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hsetEnabledTextCheckingTypes:
Sets the default text checking types.
Parameters
- checkingTypes
The types of text checking to perform by default. See
NSTextCheckingTypesfor possible values.
Availability
- Available in OS X v10.6 and later.
See Also
Declared In
NSTextView.hsetFieldEditor:
Controls whether the text views sharing the receiver’s layout manager behave as field editors.
Parameters
- flag
YESto cause the text views sharing the receiver's layout manager to behave as field editors,NOotherwise.
Discussion
Field editors interpret Tab, Shift-Tab, and Return (Enter) as cues to end editing and possibly to change the first responder. Non-field editors instead accept these characters as text input. See “Text Fields, Text Views, and the Field Editor” for more information on field editors. By default, text views don’t behave as field editors.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hsetGrammarCheckingEnabled:
Enables and disables grammar checking.
Discussion
If grammar checking is enabled, then it is performed alongside spell checking, whenever the text view checks spelling, whether continuously or manually.
Availability
- Available in OS X v10.5 and later.
Declared In
NSTextView.hsetImportsGraphics:
Controls whether the text views sharing the receiver’s layout manager allow the user to import files by dragging.
Parameters
- flag
YESto allow the user to import files by dragging onto the text views sharing the receiver’s layout manager,NOotherwise.
Discussion
Text views that are set to accept dragged files are also set to allow rich text. By default, text views don’t accept dragged files but do allow rich text.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hsetIncrementalSearchingEnabled:
Sets whether incremental searching is enabled.
Parameters
- flag
Specifies whether incremental searching is enabled for this text view.
Discussion
See NSTextFinder Class Reference for information about the find bar.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTextView.hsetInsertionPointColor:
Sets the color of the insertion point
Parameters
- aColor
The new color.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hsetLayoutOrientation:
Changes the receiver's layout orientation and invalidates the contents.
Parameters
- theOrientation
The text layout orientation.
Discussion
Unlike other NSTextView properties, this is not shared by sibling views. It also rotates the bounds 90 degrees, swaps horizontal and vertical bits of the autoresizingMask mask, and reconfigures isHorizontallyResizable and isVerticallyResizable properties accordingly. Also, if enclosingScrollView returns non-nil, it reconfigures the horizontal and vertical ruler views, the horizontal and vertical scrollers, and the frame.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTextView.hsetLinkTextAttributes:
Sets the attributes used to draw the onscreen presentation of link text.
Parameters
- attributeDictionary
A dictionary of attributes corresponding to the onscreen presentation of link text.
Discussion
Link text attributes are applied as temporary attributes to any text with a link attribute. Candidates include those attributes that do not affect layout.
In applications created prior to OS X v10.3, the default value is an empty dictionary. In applications created with OS X v10.3 or greater, the default attributes specify blue text with a single underline and the pointing hand cursor.
Availability
- Available in OS X v10.3 and later.
See Also
Declared In
NSTextView.hsetMarkedTextAttributes:
Sets the attributes used to draw marked text.
Parameters
- attributes
A dictionary of attributes used to draw marked text. Text color, background color, and underline are the only supported attributes for marked text.
Availability
- Available in OS X v10.0 and later.
See Also
-
– markedTextAttributes -
markedRange(NSTextInput)
Declared In
NSTextView.hsetNeedsDisplayInRect:avoidAdditionalLayout:
Marks the receiver as requiring display.
Parameters
- aRect
The rectangle in which display is required.
- flag
A value of
YEScauses the receiver to not perform any layout, even if this means that portions of the text view remain empty. Otherwise the receiver performs at least as much layout as needed to display aRect.
Discussion
NSTextView overrides the NSViewsetNeedsDisplayInRect: method to invoke this method with a flag argument of NO.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hsetRichText:
Controls whether the text views sharing the receiver’s layout manager allow the user to apply attributes to specific ranges of text.
Parameters
- flag
YESto allow the user to apply attributes to specific ranges of text in text views sharing the receiver’s layout manager,NOotherwise.
Discussion
Text fields that don't allow rich text also don't accept dragged files. By default, text views let the user apply multiple attributes to text, but don’t accept dragged files.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hsetRulerVisible:
Controls whether the scroll view enclosing text views sharing the receiver’s layout manager displays the ruler.
Parameters
- flag
YESto show the ruler,NOto hide the ruler. By default, the ruler is hidden.
Availability
- Available in OS X v10.0 and later.
See Also
-
– setUsesRuler: -
– isRulerVisible -
toggleRuler:(NSText)
Declared In
NSTextView.hsetSelectable:
Controls whether the text views sharing the receiver’s layout manager allow the user to select text.
Parameters
- flag
YESto allow the user to select text of all text views sharing the receiver's layout manager; otherwise,NO.
Discussion
If a text view is made not selectable, it’s also made not editable, and buttons on the Find panel are dimmed. Text views are by default both editable and selectable.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hsetSelectedRange:
Sets the selection to the characters in a single range.
Parameters
- charRange
The range of characters to select. This range must begin and end on glyph boundaries and not split base glyphs and their nonspacing marks.
Discussion
This method sets the selection to the characters in charRange, resets the selection granularity to NSSelectByCharacter, and posts an NSTextViewDidChangeSelectionNotification to the default notification center. It also removes the marking from marked text if the new selection is greater than the marked region.
Special Considerations
In OS X version 10.4 and later, if there are multiple selections, this method acts on the first selected subrange.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hsetSelectedRange:affinity:stillSelecting:
Sets the selection to a range of characters in response to user action.
Parameters
- charRange
The range of characters to select. This range must begin and end on glyph boundaries and not split base glyphs and their nonspacing marks.
- affinity
The selection affinity for the selection. See
selectionAffinityfor more information about how affinities work.- flag
YESto behave appropriately for a continuing selection where the user is still dragging the mouse,NOotherwise. IfYES, the receiver doesn’t send notifications or remove the marking from its marked text. IfNO, the receiver posts anNSTextViewDidChangeSelectionNotificationto the default notification center and removes the marking from marked text if the new selection is greater than the marked region.
Discussion
This method resets the selection granularity to NSSelectByCharacter.
Special Considerations
In OS X version 10.4 and later, if there are multiple selections, this method acts on the first selected subrange.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hsetSelectedRanges:
Sets the selection to the characters in an array of ranges.
Parameters
- ranges
A non-nil, non-empty array of objects responding to the NSValue
rangeValuemethod. The ranges in the ranges array must begin and end on glyph boundaries and not split base glyphs and their nonspacing marks.
Discussion
Sets the selection to the characters in the ranges array, resets the selection granularity to NSSelectByCharacter, and posts an NSTextViewDidChangeSelectionNotification to the default notification center. Also removes the marking from marked text if the new selection is greater than the marked region.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTextView.hsetSelectedRanges:affinity:stillSelecting:
Sets the selection to the characters in an array of ranges in response to user action.
Parameters
- ranges
A non-nil, non-empty array of objects responding to the NSValue
rangeValuemethod. The ranges in the ranges array must begin and end on glyph boundaries and not split base glyphs and their nonspacing marks.- affinity
The selection affinity for the selection. See
selectionAffinityfor more information about how affinities work.- stillSelectingFlag
YESto behave appropriately for a continuing selection where the user is still dragging the mouse,NOotherwise. IfYES, the receiver doesn’t send notifications or remove the marking from its marked text. IfNO, the receiver posts anNSTextViewDidChangeSelectionNotificationto the default notification center and removes the marking from marked text if the new selection is greater than the marked region.
Discussion
This method also resets the selection granularity to NSSelectByCharacter.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTextView.hsetSelectedTextAttributes:
Sets the attributes used to indicate the selection.
Parameters
- attributes
A dictionary of attributes used to indicate the selection. Text color, background color, and underline are the only supported attributes for selected text.
Availability
- Available in OS X v10.0 and later.
See Also
-
selectedRange(NSTextInput) -
– selectedTextAttributes
Declared In
NSTextView.hsetSelectionGranularity:
Sets the selection granularity for subsequent extension of a selection.
Parameters
- granularity
The new granularity for selection extension.
Discussion
Selection granularity is used to determine how the selection is modified when the user Shift-clicks or drags the mouse after a double or triple click. For example, if the user selects a word by double-clicking, the selection granularity is set to NSSelectByWord. Subsequent Shift-clicks then extend the selection by words.
Selection granularity is reset to NSSelectByCharacter whenever the selection is set. You should always set the selection granularity after setting the selection.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hsetSmartInsertDeleteEnabled:
Controls whether the receiver inserts or deletes space around selected words so as to preserve proper spacing and punctuation.
Parameters
- flag
YESif the receiver should insert or delete space around selected words so as to preserve proper spacing and punctuation,NOif it should insert and delete exactly what’s selected.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hsetSpellingState:range:
Sets the spelling state, which controls the display of the spelling and grammar indicators on the given text range.
Parameters
- value
The spelling state value to set. Possible values, for the temporary attribute on the layout manager using the key
NSSpellingStateAttributeName, are:NSSpellingStateSpellingFlagto highlight spelling issues.NSSpellingStateGrammarFlagto highlight grammar issues.
- charRange
The character range over which to set the given spelling state.
Discussion
May be called or overridden to control setting of spelling and grammar indicators on text, used to highlight portions of the text that are flagged for spelling or grammar issues.
Calls the method setEnabledTextCheckingTypes:.
Availability
- Available in OS X v10.5 and later.
Declared In
NSTextView.hsetTextContainer:
Sets the receiver’s text container.
Parameters
- aTextContainer
The new text container.
Discussion
The receiver uses the layout manager and text storage of aTextContainer.
Special Considerations
This method is invoked automatically when you create a text view; you should never invoke it directly, but might want to override it. To change the text view for an established group of text system objects, send setTextView: to the text container. To replace the text container for a text view and maintain the view’s association with the existing layout manager and text storage, use replaceTextContainer:.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hsetTextContainerInset:
Sets the empty space the receiver leaves around its associated text container.
Parameters
- inset
The empty space to leave around the text view's text container.
Discussion
It is possible to set the text container and view sizes and resizing behavior so that the inset cannot be maintained exactly, although the text system tries to maintain the inset wherever possible. In any case, the textContainerOrigin and size of the text container are authoritative as to the location of the text container within the view.
The text itself can have an additional inset, inside the text container, specified by the setLineFragmentPadding: method of NSTextContainer.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hsetTypingAttributes:
Sets the receiver’s typing attributes.
Parameters
- attributes
A dictionary of the new typing attributes.
Discussion
Typing attributes are reset automatically whenever the selection changes. However, if you add any user actions that change text attributes, the action should use this method to apply those attributes afterwards. User actions that change attributes should always set the typing attributes because there might not be a subsequent change in selection before the next typing.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hsetUsesFindBar:
Use the find bar interface for this text view.
Parameters
- flag
Specifies whether to use the find bar for this text view.
Discussion
See NSTextFinder Class Reference for information about the find bar.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTextView.hsetUsesFindPanel:
Specifies whether the receiver allows for a find panel.
Parameters
- flag
YESto allow the use of a find panel,NOotherwise.
Availability
- Available in OS X v10.3 and later.
See Also
Declared In
NSTextView.hsetUsesFontPanel:
Controls whether the text views sharing the receiver’s layout manager use the Font panel and Font menu.
Parameters
- flag
YESto make the text views sharing the receiver’s layout manager respond to messages from the Font panel and from the Font menu, and update the Font panel with the selection font whenever it changes,NOto disallow character attribute changes.
Discussion
By default, text view objects use the Font panel and menu.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hsetUsesInspectorBar:
Sets whether this text view uses the inspector bar.
Parameters
- flag
Specifies whether this text view uses the inspector bar.
Discussion
The inspector bar displays text formatting controls, much like those in iWork applications, which can be used in place of the formatting controls in the ruler accessory view.
Availability
- Available in OS X v10.7 and later.
See Also
Declared In
NSTextView.hsetUsesRuler:
Controls whether the text views sharing the receiver’s layout manager use a ruler.
Parameters
- flag
YESto cause text views sharing the receiver's layout manager to respond toNSRulerViewclient messages and to paragraph-related menu actions, and update the ruler (when visible) as the selection changes with its paragraph and tab attributes, otherwiseNO.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hshouldChangeTextInRange:replacementString:
Initiates a series of delegate messages (and general notifications) to determine whether modifications can be made to the characters and attributes of the receiver’s text.
Parameters
- affectedCharRange
The range of characters affected by the proposed change.
- replacementString
The characters that will replace those in affectedCharRange. If only text attributes are being changed, replacementString is
nil.
Return Value
YES to allow the change, NO to prohibit it.
Discussion
This method checks with the delegate as needed using textShouldBeginEditing: and textView:shouldChangeTextInRange:replacementString:.
This method must be invoked at the start of any sequence of user-initiated editing changes. If your subclass of NSTextView implements new methods that modify the text, make sure to invoke this method to determine whether the change should be made. If the change is allowed, complete the change by invoking the didChangeText method. If you can’t determine the affected range or replacement string before beginning changes, pass (NSNotFound, 0) and nil for these values.
Special Considerations
If the receiver is not editable, this method automatically returns NO. This result prevents instances in which a text view could be changed by user actions even though it had been set to be non-editable.
In OS X version 10.4 and later, if there are multiple selections, this method acts on the first selected subrange.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hshouldChangeTextInRanges:replacementStrings:
Initiates a series of delegate messages (and general notifications) to determine whether modifications can be made to the characters and attributes of the receiver’s text.
Parameters
- affectedRanges
An array of ranges to change.
- replacementStrings
An array of strings containing the characters that replace those in affectedRanges, one for each range. If only text attributes are being changed, replacementStrings is
nil.
Return Value
YES to allow the change, NO to prohibit it.
Discussion
This method checks with the delegate as needed using textShouldBeginEditing: and textView:shouldChangeTextInRanges:replacementStrings:.
This method must be invoked at the start of any sequence of user-initiated editing changes. If your subclass of NSTextView implements new methods that modify the text, make sure to invoke this method to determine whether the change should be made. If the change is allowed, complete the change by invoking the didChangeText method. If you can’t determine the affected range or replacement string before beginning changes, pass nil for these values.
Special Considerations
If the receiver is not editable, this method automatically returns NO. This result prevents instances in which a text view could be changed by user actions even though it had been set to be non-editable.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTextView.hshouldDrawInsertionPoint
Returns whether the receiver should draw its insertion point.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hshowFindIndicatorForRange:
Causes a temporary highlighting effect to appear around the visible portion (or portions) of the specified range.
Parameters
- charRange
The character range around which indicators appear.
Discussion
This method supports lozenge-style indication of find results. The indicators automatically disappear after a certain period of time, or when the method is called again, or when any of a number of changes occur to the view (such as changes to text, view size, or view position).
This method does not itself scroll the specified range to be visible; any desired scrolling should be done before this method is called, first, because the method acts only on the visible portion of the specified range, and, second, because scrolling causes the indicators to disappear. Calling this method with a zero-length range always removes any existing indicators.
Availability
- Available in OS X v10.5 and later.
Declared In
NSTextView.hsmartDeleteRangeForProposedRange:
Returns an extended range that includes adjacent whitespace that should be deleted along with the proposed range in order to preserve proper spacing and punctuation.
Parameters
- proposedCharRange
The proposed character range for deleting.
Return Value
An extended range that includes adjacent whitespace that should be deleted along with the proposed range in order to preserve proper spacing and punctuation of the text surrounding the deletion.
Discussion
NSTextView uses this method as necessary; you can also use it in implementing your own methods that delete text, typically when the selection granularity is NSSelectByWord. To do so, invoke this method with the proposed range to delete, then actually delete the range returned. If placing text on the pasteboard, however, you should put only the characters from the proposed range onto the pasteboard.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hsmartInsertAfterStringForString:replacingRange:
Returns any whitespace that needs to be added after the string to preserve proper spacing and punctuation when the string replaces the characters in the specified range.
Parameters
- aString
The string that is replacing the characters in charRange.
- charRange
The range of characters which aString is replacing.
Return Value
Any whitespace that needs to be added after aString to preserve proper spacing and punctuation when the characters in charRange are replaced by aString. If aString is nil or if smart insertion and deletion are disabled, this method returns nil.
Discussion
Don’t invoke this method directly. Instead, use smartInsertForString:replacingRange:beforeString:afterString:, which calls this method as part of its implementation.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hsmartInsertBeforeStringForString:replacingRange:
Returns any whitespace that needs to be added before the string to preserve proper spacing and punctuation when the string replaces the characters in the specified range.
Parameters
- aString
The string that is replacing the characters in charRange.
- charRange
The range of characters which aString is replacing.
Return Value
Any whitespace that needs to be added before aString to preserve proper spacing and punctuation when the characters in charRange are replaced by aString. If aString is nil or if smart insertion and deletion are disabled, this method returns nil.
Discussion
Don’t invoke this method directly. Instead, use smartInsertForString:replacingRange:beforeString:afterString:, which calls this method as part of its implementation.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hsmartInsertDeleteEnabled
Returns whether the receiver inserts or deletes space around selected words so as to preserve proper spacing and punctuation.
Return Value
YES if the receiver inserts or deletes space around selected words so as to preserve proper spacing and punctuation, NO if it inserts and deletes exactly what’s selected.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hsmartInsertForString:replacingRange:beforeString:afterString:
Determines whether whitespace needs to be added around the string to preserve proper spacing and punctuation when it replaces the characters in the specified range.
Parameters
- aString
The string that is replacing the characters in charRange.
- charRange
The range of characters which aString is replacing.
- beforeString
On return, a pointer to the string with the characters that should be added before aString;
nilif there are no characters to add, if aString isnil, or if smart insertion and deletion are disabled.- afterString
On return, a pointer to the string with the characters that should be added after aString;
nilif there are no characters to add, if aString isnil, or if smart insertion and deletion are disabled.
Discussion
As part of its implementation, this method calls smartInsertAfterStringForString:replacingRange: and smartInsertBeforeStringForString:replacingRange:. To change this method’s behavior, override those two methods instead of this one.
NSTextView uses this method as necessary. You can also use it in implementing your own methods that insert text. To do so, invoke this method with the proper arguments, then insert beforeString, aString, and afterString in order over charRange.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hspellCheckerDocumentTag
Returns a tag identifying the text view's text as a document for the spell checker server.
Return Value
A tag identifying the text view's text as a document for the spell checker server.
Discussion
The document tag is obtained by sending a uniqueSpellDocumentTag message to the spell server the first time this method is invoked for a particular group of text views. See the NSSpellCheckerand NSSpellServerclass specifications for more information on how this tag is used.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hstartSpeaking:
Speaks the selected text, or all text if no selection.
Parameters
- sender
The control sending the message; can be
nil.
Availability
- Available in OS X v10.1 and later.
See Also
Declared In
NSTextView.hstopSpeaking:
Stops the speaking of text.
Parameters
- sender
The control sending the message; can be
nil.
Availability
- Available in OS X v10.1 and later.
See Also
Declared In
NSTextView.htextContainer
Returns the receiver’s text container.
Return Value
The receiver's text container.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.htextContainerInset
Returns the empty space the receiver leaves around its text container.
Return Value
The empty space the receiver leaves around its text container.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.htextContainerOrigin
Returns the origin of the receiver’s text container.
Return Value
The origin of the receiver’s text container, which is calculated from the receiver’s bounds rectangle, container inset, and the container’s used rect.
Availability
- Available in OS X v10.0 and later.
See Also
-
– invalidateTextContainerOrigin -
– textContainerInset -
usedRectForTextContainer:(NSLayoutManager)
Declared In
NSTextView.htextStorage
Returns the receiver’s text storage object.
Return Value
The receiver’s text storage object.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.htightenKerning:
Decreases the space between glyphs in the receiver’s selection, or for all glyphs if the receiver is a plain text view.
Parameters
- sender
The control that sent the message; may be
nil.
Discussion
Kerning values are determined by the point size of the fonts in the selection.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.htoggleAutomaticDashSubstitution:
Toggles the state of the automatic dash substitution.
Parameters
- sender
The control sending the message. May be
nil.
Discussion
Turning on automatic dash substitution enables automatic conversion of sequences of ASCII hyphen (-) characters to typographic dashes.
Availability
- Available in OS X v10.6 and later.
Declared In
NSTextView.htoggleAutomaticDataDetection:
Toggles the state of the automatic data detection.
Parameters
- sender
The control sending the message. May be
nil.
Discussion
Automatic data detection enables detection of dates, addresses, and phone numbers.
Availability
- Available in OS X v10.6 and later.
Declared In
NSTextView.htoggleAutomaticLinkDetection:
Changes the state of automatic link detection from enabled to disabled and vice versa.
Parameters
- sender
The control sending the message; may be
nil.
Discussion
Automatic link detection causes strings representing URLs typed in the view to be automatically made into links to those URLs.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSTextView.htoggleAutomaticQuoteSubstitution:
Changes the state of automatic quotation mark substitution from enabled to disabled and vice versa.
Parameters
- sender
The control sending the message; may be
nil.
Discussion
Automatic quote substitution causes ASCII quotation marks and apostrophes to be automatically replaced, on a context-dependent basis, with more typographically accurate symbols.
Availability
- Available in OS X v10.5 and later.
Declared In
NSTextView.htoggleAutomaticSpellingCorrection:
Toggles the state of the automatic spelling correction.
Parameters
- sender
The control sending the message. May be
nil.
Availability
- Available in OS X v10.6 and later.
Declared In
NSTextView.htoggleAutomaticTextReplacement:
Toggles the state of the automatic text replacement.
Parameters
- sender
The control sending the message. May be
nil.
Discussion
Turning on automatic text replacement enables automatic substitution of a variety of static text items based on user preferences.
Availability
- Available in OS X v10.6 and later.
Declared In
NSTextView.htoggleContinuousSpellChecking:
Toggles whether continuous spell checking is enabled for the receiver.
Parameters
- sender
The control sending the message; may be
nil.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.htoggleGrammarChecking:
Changes the state of grammar checking from enabled to disabled and vice versa.
Parameters
- sender
The control sending the message; may be
nil.
Availability
- Available in OS X v10.5 and later.
Declared In
NSTextView.htoggleQuickLookPreviewPanel:
An action message that toggles the visibility state of the Quick Look preview panel.
Parameters
- sender
The message sender.
Discussion
This action message toggles the visibility state of the Quick Look preview panel if the receiver is the current Quick Look controller.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTextView.htoggleSmartInsertDelete:
Changes the state of smart insert and delete from enabled to disabled and vice versa.
Parameters
- sender
The control sending the message; may be
nil.
Discussion
Controls whether the receiver inserts or deletes space around selected words so as to preserve proper spacing and punctuation.
Availability
- Available in OS X v10.5 and later.
Declared In
NSTextView.htoggleTraditionalCharacterShape:
Toggles the NSCharacterShapeAttributeName attribute at the current selection.
Parameters
- sender
The control that sent the message; may be
nil.
Discussion
The NSCharacterShapeAttributeName constant is defined in NSAttributedString Application Kit Additions Reference.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hturnOffKerning:
Sets the receiver to use nominal glyph spacing for the glyphs in its selection, or for all glyphs if the receiver is a plain text view.
Parameters
- sender
The control that sent the message; may be
nil.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hturnOffLigatures:
Sets the receiver to use only required ligatures when setting text, for the glyphs in the selection if the receiver is a rich text view, or for all glyphs if it’s a plain text view.
Parameters
- sender
The control that sent the message; may be
nil.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.htypingAttributes
Returns the current typing attributes.
Return Value
A dictionary of the current typing attributes.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hupdateDragTypeRegistration
Updates the acceptable drag types of all text views associated with the receiver's layout manager.
Discussion
If the receiver is editable and is a rich text view, causes all text views associated with the receiver’s layout manager to register their acceptable drag types. If the text view isn’t editable or isn’t rich text, causes those text views to unregister their dragged types.
Subclasses can override this method to change the conditions for registering and unregistering drag types, whether as a group or individually based on the current state of the text view. They should invoke this method when that state changes to perform the necessary update.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hupdateFontPanel
Updates the Font panel to contain the font attributes of the selection.
Discussion
Does nothing if the receiver doesn’t use the Font panel. You should never need to invoke this method directly, but you can override it if needed to handle additional font attributes.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hupdateInsertionPointStateAndRestartTimer:
Updates the insertion point’s location and optionally restarts the blinking cursor timer.
Parameters
- flag
YESto restart the blinking cursor timer,NOotherwise.
Discussion
This method is invoked automatically whenever the insertion point needs to be moved; you should never need to invoke it directly, but you can override it to modify insertion point behavior.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hupdateQuickLookPreviewPanel
Notifies the QuickLook panel that an update may be required.
Discussion
Notifies the QLPreviewPanel class for possible status changes with the data source or controller. Typically invoked in response to selection changes.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTextView.hupdateRuler
Updates the ruler view in the receiver’s enclosing scroll view to reflect the selection’s paragraph and marker attributes.
Discussion
Does nothing if the ruler isn’t visible or if the receiver doesn’t use the ruler. You should never need to invoke this method directly, but you can override this method if needed to handle additional ruler attributes.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.huseAllLigatures:
Sets the receiver to use all ligatures available for the fonts and languages used when setting text, for the glyphs in the selection if the receiver is a rich text view, or for all glyphs if it’s a plain text view.
Parameters
- sender
The control that sent the message; may be
nil.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.husesFindBar
Returns whether the text view uses the find bar.
Return Value
YES if the find bar is used for this text view; otherwise NO.
Discussion
See NSTextFinder Class Reference for information about the find bar.
Availability
- Available in OS X v10.7 and later.
Declared In
NSTextView.husesFindPanel
Returns whether the receiver allows for a find panel.
Return Value
YES if the receiver allows the use of a find panel, NO otherwise.
Availability
- Available in OS X v10.3 and later.
See Also
Declared In
NSTextView.husesFontPanel
Returns whether the text views sharing the receiver’s layout manager use the Font panel.
Return Value
YES if the text views sharing the receiver’s layout manager use the Font panel, NO otherwise.
Discussion
See setUsesFontPanel: and rangeForUserCharacterAttributeChange for the effect this method has on a text view's behavior.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.husesInspectorBar
Returns whether this text view uses the inspector bar.
Return Value
YES if the text view uses the inspector bar; otherwise NO.
Availability
- Available in OS X v10.7 and later.
See Also
Declared In
NSTextView.husesRuler
Returns whether the text views sharing the receiver’s layout manager use a ruler.
Return Value
YES if the text views sharing the receiver’s layout manager use a ruler, NO otherwise.
Discussion
See setUsesRuler: and rangeForUserParagraphAttributeChange for the effect this has on a text view's behavior. By default, text view objects use the ruler.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.huseStandardKerning:
Set the receiver to use pair kerning data for the glyphs in its selection, or for all glyphs if the receiver is a plain text view.
Parameters
- sender
The control that sent the message; may be
nil.
Discussion
This data is taken from a font’s AFM file
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.huseStandardLigatures:
Sets the receiver to use the standard ligatures available for the fonts and languages used when setting text, for the glyphs in the selection if the receiver is a rich text view, or for all glyphs if it’s a plain text view.
Parameters
- sender
The control that sent the message; may be
nil.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hvalidRequestorForSendType:returnType:
Returns self if the text view can provide and accept the specified data types, or nil if it can't.
Parameters
- sendType
The type of data requested.
- returnType
The type of data that will be returned.
Return Value
self if sendType specifies a type of data the text view can put on the pasteboard and returnType contains a type of data the text view can read from the pasteboard; otherwise nil.
Availability
- Available in OS X v10.0 and later.
See Also
-
validRequestorForSendType:returnType:(NSResponder)
Declared In
NSTextView.hwritablePasteboardTypes
Returns the pasteboard types that can be provided from the current selection.
Return Value
An array of strings describing the types that can be written to the pasteboard immediately, or an array with no members if the text view has no text or no selection.
Discussion
Overriders can copy the result from super and add their own new types.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hwriteSelectionToPasteboard:type:
Writes the current selection to the specified pasteboard using the given type.
Parameters
- pboard
The pasteboard to write to.
- type
The type of data to write.
Return Value
YES if the data was successfully written, NO otherwise.
Discussion
The complete set of data types being written to pboard should be declared before invoking this method.
This method should be invoked only from writeSelectionToPasteboard:types:. You can override this method to add support for writing new types of data to the pasteboard. You should invoke super’s implementation of the method to handle any types of data your overridden version does not.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTextView.hwriteSelectionToPasteboard:types:
Writes the current selection to the specified pasteboard under each given type.
Parameters
- pboard
The pasteboard to write to.
- types
An array of strings describing the types of data to write.
Return Value
YES if the data for any single type was successfully written, NO otherwise.
Discussion
This method declares the data types on pboard and then invokes writeSelectionToPasteboard:type: or the delegate method textView:writeCell:atIndex:toPasteboard:type: for each type in the types array.
You should not need to override this method. You might need to invoke this method if you are implementing a new type of pasteboard to handle services other than copy/paste or dragging.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hConstants
NSSelectionGranularity
These constants specify how much the text view extends the selection when the user drags the mouse. They’re used by selectionGranularity, setSelectionGranularity:, and selectionRangeForProposedRange:granularity::
enum {
NSSelectByCharacter = 0,
NSSelectByWord = 1,
NSSelectByParagraph = 2
};
typedef NSUInteger NSSelectionGranularity;
Constants
NSSelectByCharacterExtends the selection character by character.
Available in OS X v10.0 and later.
Declared in
NSTextView.h.NSSelectByWordExtends the selection word by word.
Available in OS X v10.0 and later.
Declared in
NSTextView.h.NSSelectByParagraphExtends the selection paragraph by paragraph.
Available in OS X v10.0 and later.
Declared in
NSTextView.h.
Declared In
NSTextView.hNSSelectionAffinity
These constants specify the preferred direction of selection. They’re used by selectionAffinity and setSelectedRange:affinity:stillSelecting:.
enum {
NSSelectionAffinityUpstream = 0,
NSSelectionAffinityDownstream = 1
};
typedef NSUInteger NSSelectionAffinity;
Constants
NSSelectionAffinityUpstreamThe selection is moving toward the top of the document.
Available in OS X v10.0 and later.
Declared in
NSTextView.h.NSSelectionAffinityDownstreamThe selection is moving toward the bottom of the document.
Available in OS X v10.0 and later.
Declared in
NSTextView.h.
Declared In
NSTextView.hNSFindPanelAction
These constants define the tags for performFindPanelAction:. (Deprecated. These constants are deprecated in favor of the NSTextFinder equivalent constants defined in NSTextFinderAction constants.)
enum {
NSFindPanelActionShowFindPanel = 1,
NSFindPanelActionNext = 2,
NSFindPanelActionPrevious = 3,
NSFindPanelActionReplaceAll = 4,
NSFindPanelActionReplace = 5,
NSFindPanelActionReplaceAndFind = 6,
NSFindPanelActionSetFindString = 7,
NSFindPanelActionReplaceAllInSelection = 8
};
typedef NSUInteger NSFindPanelAction;
Constants
NSFindPanelActionShowFindPanelDisplays the find panel.
Available in OS X v10.3 and later.
Declared in
NSTextView.h.NSFindPanelActionNextFinds the next instance of the queried text.
Available in OS X v10.3 and later.
Declared in
NSTextView.h.NSFindPanelActionPreviousFinds the previous instance of the queried text.
Available in OS X v10.3 and later.
Declared in
NSTextView.h.NSFindPanelActionReplaceAllReplaces all query instances within the text view.
Available in OS X v10.3 and later.
Declared in
NSTextView.h.NSFindPanelActionReplaceReplaces a single query instance within the text view.
Available in OS X v10.3 and later.
Declared in
NSTextView.h.NSFindPanelActionReplaceAndFindReplaces a single query instance and finds the next.
Available in OS X v10.3 and later.
Declared in
NSTextView.h.NSFindPanelActionSetFindStringSets the query string to the current selection.
Available in OS X v10.3 and later.
Declared in
NSTextView.h.NSFindPanelActionReplaceAllInSelectionReplaces all query instances within the selection.
Available in OS X v10.3 and later.
Declared in
NSTextView.h.NSFindPanelActionSelectAllSelects all query instances in the text view.
Available in OS X v10.4 and later.
Declared in
NSTextView.h.NSFindPanelActionSelectAllInSelectionSelects all query instances within the selection.
Available in OS X v10.4 and later.
Declared in
NSTextView.h.
Declared In
NSTextView.hInput Sources Locale Identifiers
Locale identifiers represent the input sources available.
NSString *NSAllRomanInputSourcesLocaleIdentifier
Constants
NSAllRomanInputSourcesLocaleIdentifierA meta-locale identifier representing the set of Roman input sources available. You can pass
[NSArray arrayWithObject: NSAllRomanInputSourcesLocaleIdentifier]to thesetAllowedInputSourceLocales:method to restrict allowed input sources to Roman only.Available in OS X v10.5 and later.
Declared in
NSTextView.h.
Declared In
NSTextView.hFind Panel Search Metadata
In addition to communicating search strings via the find pasteboard, the standard Find panel for NSTextView also communicates search option metadata, including case sensitivity and substring matching options. This metadata is stored in a property list as the NSFindPanelSearchOptionsPboardType value on the global find pasteboard. As such, third party applications may store additional keys in this property list to communicate additional metadata as desired to support the various search options common to many third-party applications' Find panels.
NSString *NSFindPanelSearchOptionsPboardType NSString *NSFindPanelCaseInsensitiveSearch NSString *NSFindPanelSubstringMatch
Constants
NSFindPanelSearchOptionsPboardTypeType for
NSFindPanelmetadata property list. Used with theNSPasteBoardmethodpropertyListForType:.Available in OS X v10.5 and later.
Declared in
NSTextView.h.NSFindPanelCaseInsensitiveSearchBoolean value specifying whether the search is case-insensitive.
YESspecifies a case-insensitive search; otherwise,NO.Available in OS X v10.5 and later.
Declared in
NSTextView.h.NSFindPanelSubstringMatchNSNumberobject containing one of the values defined in “NSFindPanelSubstringMatchType.”Available in OS X v10.5 and later.
Declared in
NSTextView.h.
Declared In
NSTextView.hNSFindPanelSubstringMatchType
The type of substring matching used by the Find panel.
enum {
NSFindPanelSubstringMatchTypeContains = 0,
NSFindPanelSubstringMatchTypeStartsWith = 1,
NSFindPanelSubstringMatchTypeFullWord = 2,
NSFindPanelSubstringMatchTypeEndsWith = 3
};
typedef NSUInteger NSFindPanelSubstringMatchType;
Constants
NSFindPanelSubstringMatchTypeContainsFinds a word containing the search string.
Available in OS X v10.5 and later.
Declared in
NSTextView.h.NSFindPanelSubstringMatchTypeStartsWithFinds a word starting with the search string.
Available in OS X v10.5 and later.
Declared in
NSTextView.h.NSFindPanelSubstringMatchTypeFullWordFinds a word exactly matching the search string.
Available in OS X v10.5 and later.
Declared in
NSTextView.h.NSFindPanelSubstringMatchTypeEndsWithFinds a word ending with the search string.
Available in OS X v10.5 and later.
Declared in
NSTextView.h.
Declared In
NSTextView.hNotifications
NSTextView posts the following notifications as well as those declared by its superclasses, particularly NSText. See the “Notifications” in NSText Class Reference section in the NSText class specification for those other notifications.
NSTextViewDidChangeSelectionNotification
NSTextView posts this notification whenever setSelectedRange:affinity:stillSelecting: is invoked, either directly or through the many methods (mouseDown:, selectAll:, and so on) that invoke it indirectly. When the user is selecting text, this notification is posted only once, at the end of the selection operation. The text view's delegate receives a textViewDidChangeSelection: message when this notification is posted.
The notification object is the notifying text view. The userInfo dictionary contains the following information:
Key | Value |
|---|---|
| An |
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextView.hNSTextViewWillChangeNotifyingTextViewNotification
This notification allows observers to reregister themselves for the new text view. Methods such as removeTextContainerAtIndex:, textContainerChangedTextView:, and insertTextContainer:atIndex: cause this notification to be posted.
The notification object is the old notifying text view, or nil. The userInfo dictionary contains the following information:
Key | Value |
|---|---|
| The old |
| The new |
There’s no delegate method associated with this notification. The text-handling system ensures that when a new text view replaces an old one as the notifying text view, the existing delegate becomes the delegate of the new text view, and the delegate is registered to receive text view notifications from the new notifying text view. All other observers are responsible for registering themselves on receiving this notification.
Availability
- Available in OS X v10.0 and later.
See Also
-
removeObserver:(NSNotificationCenter) -
addObserver:selector:name:object:(NSNotificationCenter)
Declared In
NSTextView.hNSTextViewDidChangeTypingAttributesNotification
textViewDidChangeTypingAttributes: delegate method, whether or not text has changed as a result of the attribute change.Availability
- Available in OS X v10.3 and later.
Declared In
NSTextView.h© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-12-13)