- Inherits from:
- NSText : NSView : NSResponder : NSObject
- Conforms to:
- NSTextInput
- NSChangeSpelling (NSText)
- NSIgnoreMisspelledWords (NSText)
- NSCoding (NSResponder)
- NSObject (NSObject)
Declared in:
- AppKit/NSTextView.h
NSTextView is the front-end component of the Application Kit's text system. It displays and manipulates text laid out in an area defined by an NSTextContainer, and adds many features to those defined by its superclass, NSText. Many of the methods that you'll use most frequently are declared by the superclass; see the NSText class specification for details.
Instances of this class can be created using Interface Builder or using one of .the following methods:
- initWithFrame: | Creates an NSTextView along with all its supporting objects. |
- initWithFrame:textContainer: | Designated initializer. |
The methods most commonly used with NSTextView objects are declared in NSText, the superclass. These methods provide access to the other major components of the text system:
- textStorage | Returns the associated NSTextStorage object. |
- textContainer | Returns the associated NSTextContainer object. |
- layoutManager | Returns the associated NSLayoutManager object. |
NSTextView is the front-end class to the Application Kit's extended text-handling system. It 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 NSText-which declares the most general Cocoa interface to the text system-NSTextView adds several major features over and above the capabilities of NSText.
One of the design goals of NSTextView is to provide a comprehensive set of text-handling features so that you should rarely need to create a subclass. In its standard incarnation, NSTextView creates the requisite group of objects that support the text handling system-NSTextContainer, NSLayoutManager, and NSTextStorage objects. Here are the major features that NSTextView adds to those of NSText:
The easiest way to add an NSTextView to your application is through Interface Builder. Interface Builder's Data Views palette supplies a specially configured NSScrollView object that contains an NSTextView object as its document view. This NSTextView is configured to work with the NSScrollView and other user-interface controls such as a ruler, the Font menu, the Edit menu, and so on.
Interface Builder also offers other objects-of the NSTextField and NSForm classes-that make use of NSTextView objects for their text-editing facilities. In fact, all NSTextFields and NSForms within the same window share the same NSTextView object (known as the field editor), thus reducing the memory demands of an application. If your application requires stand-alone or grouped text fields that support editing (and all the other facilities provided by the NSTextView class), these are the classes to use.
You can also create NSTextView objects programmatically, using either of the methods initWithFrame:textContainer: (the designated initializer), or initWithFrame:. The initWithFrame: method is the simplest way to obtain an NSTextView object-it creates all the other components of the text-handling system for you and releases them when you're done. If you use initWithFrame:textContainer:, you must construct (and release) the other components yourself.
Like NSText, NSTextView allows you to grant or deny the user the ability to select or edit its text, using the setSelectable: and setEditable: methods. These methods only affect what the user can do; you can still make changes to the NSTextView programmatically. An editable text view can behave as a normal text editor, accepting Tab and Return characters, or as a field editor, interpreting tabs and returns as cues to end editing. The setFieldEditor: method controls this behavior. NSTextView also implements the distinction between plain and rich text defined by NSText with its setRichText: and setImportsGraphics: methods. See the NSText class specification for more information on these various distinctions.
While NSText leaves open the nature of imported graphics and other attachments, NSTextView explicitly uses NSTextAttachment objects, which contain NSFileWrappers to represent the attached files. NSTextView declares several delegate methods that let you handle user actions on an attachment's image or icon. textView:clickedOnCell:inRect:atIndex: and textView:doubleClickedOnCell:inRect:atIndex: let the delegate take action on mouse clicks, textView:draggedCell:inRect:event:atIndex: lets the delegate initiate a dragging session for the attachment, and textView:clickedOnLink:atIndex: lets the delegate act on mouse clicks in a link. See the NSTextAttachment, NSTextAttachmentCell, and NSFileWrapper class and protocol specifications for more information on working with attachments.
NSTextView uses an input manager to turn basic character information
into text and commands. It passes uninterpreted keyboard input to
the input manager, which examines the characters generated and sends
messages to the NSTextView based on those characters. If the typed
characters are interpreted as text to input, the input manager sends
the text view an insertText: message.
If they're interpreted as commands to perform, such as moving
the insertion point or deleting text, the input manager sends the
text view a doCommandBySelector message.
Many of the standard commands are described in the NSResponder class
specification. NSTextView also gives its delegate a chance to handle
a command by sending it a textView:doCommandBySelector: message.
If the delegate implements this method and returns YES
,
the text view does nothing further; otherwise it tries to perform
the command itself.
See the NSInputManager class and NSTextInput protocol specifications for more information.
NSTextView is designed to work with the Application Kit's font conversion system, defined by the NSFontPanel and NSFontManager classes. By default, an NSTextView keeps the Font Panel updated with the first font in its selection, or of its typing attributes (defined below). It also changes the font in response to messages from the Font Panel and Font menu. Such changes apply to the selected text or typing attributes for a rich text view, or to all the text in a plain text view. You can turn this behavior off using the setUsesFontPanel: method. Doing so is recommended for a text view that serves as a field editor, for example. Making an NSTextView not use the font conversion system renders some of its other methods unusable, as these methods require access to font information to work. See the description of setUsesFontPanel: for these side effects.
NSTextView also defines a comprehensive interface for manipulating paragraph attributes, using the NSRulerView class. If an NSTextView is enclosed in an NSScrollView, it can display a ruler view, which displays margin and tab markers that the user can manipulate to adjust their settings, as well as other controls for setting alignment, paragraph spacing, and so on. setRulerVisible: and the inherited toggleRuler: control whether the ruler view is displayed. The NSTextView serves as the ruler view's client, as described in the NSRulerView class specification. Similar to the Font Panel, NSTextView can be set not to use a ruler with the setUsesRuler: method. This has side effects similar to those of setUsesFontPanel:.
Most of the time the selection is determined by the user through mouse or keyboard operations. You can get the range of characters currently selected using the selectedRange method. This is the single most commonly used method for examining the selection. You can also set the selection programmatically using setSelectedRange:. NSTextView indicates its selection by applying a special set of attributes to it. selectedTextAttributes returns these attributes, and setSelectedTextAttributes: sets them.
While changing the selection in response to user input, an
NSTextView invokes its setSelectedRange:affinity:stillSelecting: method.
The first argument is of course the range to select. The second, called
the selection affinity, determines which glyph the insertion point
displays near when the two glyphs aren't adjacent. It's typically
used where lines wrap to place the insertion point at the end of
one line or the beginning of the following line. You can get the
selection affinity in effect using the selectionAffinity method. The last
argument indicates whether the selection is still in the process
of changing; the delegate and any observers aren't notified of
the change in the selection until the method is invoked with NO
for
this argument. An additional factor affecting selection behavior
is the selection granularity: whether characters, words, or whole
paragraphs are being selected. This is usually determined by number
of initial clicks; for example, a double-click initiates word-level
selection. NSTextView decides how much to change the selection during
input tracking using its selectionRangeForProposedRange:granularity: method,
as described under "Subclass Responsibilities" below.
An additional aspect of selection, actually related to input management, is the range of marked text. As the input manager interprets keyboard input, it can mark incomplete input in a special way. markedRange returns the range of any marked text, and markedTextAttributes returns the attributes used to highlight the marked text. You can change these attributes using setMarkedTextAttributes:
NSTextView allows you to change the attributes of its text programmatically through various methods, most inherited from the superclass, NSText. NSTextView adds its own methods for setting the attributes of text that the user types, for setting the baseline offset of text as an absolute value, and for adjusting kerning and use of ligatures. Most of the methods for changing attributes are defined as action methods, and apply to the selected text or typing attributes for a rich text view, or to all of the text in a plain text view.
An NSTextView maintains a set of typing attributes (font, size, color, and so on) that it applies to newly entered text, whether typed by the user or pasted as plain text. It automatically sets the typing attributes to the attributes of the first character immediately preceding the insertion point, of the first character of a paragraph if the insertion point is at the beginning of a paragraph, or of the first character of a selection. The user can change the typing attributes by choosing menu commands and using utilities such as the Font Panel. You can also set the typing attributes programmatically using setTypingAttributes:, though you should rarely find need to do so unless creating a subclass.
NSText defines the action methods superscript:, subscript:, and unscript:, which raise and lower the baseline of text by predefined increments. NSTextView gives you much finer control over the baseline offset of text by defining the raiseBaseline: and lowerBaseline: action methods, which raise or lower text by one point each time they're invoked.
NSTextView provides convenient action methods for adjusting the spacing between characters. By default, an NSTextView object uses standard kerning (as provided by the data in a font's AFM file). A turnOffKerning: message causes this kerning information to be ignored and the selected text to be displayed using nominal widths. The loosenKerning: and tightenKerning: methods adjust kerning values over the selected text and useStandardKerning: reestablishes the default kerning values.
Kerning information is a character attribute that's stored in the text view's NSTextStorage object. If your application needs finer control over kerning than the methods of this class provide, you should operate on the NSTextStorage object directly through methods defined by its superclass, NSMutableAttributedString. See the NSAttributedString Class Cluster Additions specification for information on setting attributes.
NSTextView's support for ligatures provides the minimum required ligatures for a given font and script. The required ligatures for a specific font and script are determined by the mechanisms that generate glyphs for a specific language. Some scripts may well have no ligatures at all-English text, as an example, doesn't require ligatures, although certain ligatures such as "fi" and "fl" are desirable and are used if they're available. Other scripts, such as Arabic, demand that certain ligatures must be available even if a turnOffLigatures: message is sent to the NSTextView. Other scripts and fonts have standard ligatures that are used if they're available. The useAllLigatures: method extends ligature support to include all possible ligatures available in each font for a given script.
Ligature information is a character attribute that's stored in the text view's NSTextStorage object. If your application needs finer control over ligature use than the methods of this class provide, you should operate on the NSTextStorage object directly through methods defined by its superclass, NSMutableAttributedString. See the NSAttributedString Class Cluster Additions specification for information on setting attributes.
A single NSLayoutManager can be assigned any number of NSTextContainers, in whose NSTextViews it lays out text sequentially. In such a configuration, many of the attributes accessed through the NSTextView interface are actually shared by all of these text views. Among these attributes are:
Setting any of these attributes causes all associated NSTextView's to share the new value.
With multiple NSTextViews, only one is the first responder at any time. NSLayoutManager defines these methods for determining and appropriately setting the first responder:
See their descriptions in the NSLayoutManager class specification for more information.
An NSTextView object can have a delegate that it informs of certain actions or pending changes to the state of the text. Several of the delegate methods have already been mentioned; here are all the messages a delegate can receive:
Those whose names begin with "text" rather than "textView" are declared by NSText and described in the NSText class specification. See "Methods Implemented By the Delegate" at the end of this class description for more details. The delegate can be any object you choose, and one delegate can control multiple NSTextView objects (or multiple series of connected NSTextView objects).
All NSTextView objects attached to the same NSLayoutManager share the same delegate: Setting the delegate of one such NSTextView sets the delegate for all the others. Delegate messages pass the id of the sender as an argument. For multiple NSTextViews attached to the same NSLayoutManager, the id is that of the notifying text view, the first NSTextView for the shared NSLayoutManager. As the name implies, this NSTextView is also responsible for posting notifications at the appropriate times.
The notifications posted by NSTextView are:
Of these, the last is important for observers to register for. If a new NSTextView is added at the beginning of a series of connected NSTextViews, it becomes the new notifying text view. It doesn't have access to which objects are observing its group of text objects, so it posts an NSTextViewWillChangeNotifyingTextViewNotification, which allows all those observers to unregister themselves from the old notifying text view and reregister themselves with the new one. See the description for this notification at the end of this specification for more information.
NSTextView expects subclasses to abide by certain rules of behavior, and provides many methods to help subclasses do so. Some of these methods are meant to be overridden to add information and behavior into the basic infrastructure. Some are meant to be invoked as part of that infrastructure when the subclass defines its own behavior. The following sections describe the major areas where a subclass has obligations or where it can expect help in implementing its new features.
NSTextView automatically updates the Font Panel and ruler
as its selection changes. If you add any new font or paragraph attributes
to your subclass of NSTextView, you'll need to override the methods that
perform this updating to account for the added information. updateFontPanel makes
the Font Panel display the font of the first character in the selection;
you might override it to update the display of an accessory view
in the Font Panel. Similarly, updateRuler causes the ruler to display
the paragraph attributes for the first paragraph in the selection.
You can also override this to customize display of items in the
ruler. Be sure to invoke super
's
implementation to have the basic updating performed as well.
NSTextView supports pasteboard operations and the dragging
of files and colors into its text. If you customize the ability
of your subclass to handle pasteboard operations for new data types,
you should override the readablePasteboardTypes and writablePasteboardTypes methods
to reflect those types. Similarly, for to support new types of data
for dragging operations, you should override the acceptableDragTypes method.
Your implementation of these methods should invoke the superclass' implementation,
add the new data types to the array returned from super
,
and then return the modified array.
For dragging operations, if your subclass's ability to accept your custom dragging types varies over time, you can override updateDragTypeRegistration to register or unregister the custom types according to the text view's current status. By default this method enables dragging of all acceptable types if the receiver is editable and a rich text view.
To read and write custom pasteboard types, you must override the readSelectionFromPasteboard:type: and writeSelectionToPasteboard:type: methods. In your implementation of these methods, you should read the new data types your subclass supports and let the superclass handle any other types.
Your subclass of NSTextView can customize the way selections are made for the various granularities described in "Examining and Setting the Selection" . While tracking user changes to the selection, whether by the mouse or keyboard, an NSTextView repeatedly invokes selectionRangeForProposedRange:granularity: to determine what range to actually select. When finished tracking changes, it sends the delegate a textView:willChangeSelectionFromCharacterRange:toCharacterRange: message. By overriding the NSTextView method or implementing the delegate method, you can alter the way the selection is extended or reduced. For example, in a code editor you can provide a delegate that extends a double click on a brace or parenthesis character to its matching delimiter.
These mechanisms aren't meant for changing language word definitions (such as what's selected on a double click). This detail of selection is handled at a lower (and currently private) level of the text system.
If you create a subclass of NSTextView to add new capabilities
that will modify the text in response to user actions, you may need
to modify the range selected by the user before actually applying
the change. For example, if the user is making a change to the ruler,
the change must apply to whole paragraphs, so the selection may
have to be extended to paragraph boundaries. Three methods calculate
the range to which certain kinds of change should apply. rangeForUserTextChange returns
the range to which any change to characters themselves-insertions
and deletions-should apply. rangeForUserCharacterAttributeChange returns
the range to which a character attribute change, such as a new font
or color, should apply. Finally, rangeForUserParagraphAttributeChange returns
the range for a paragraph-level change, such as a new or moved tab
stop, or indent. These methods all return a range whose location
is NSNotFound
if a change isn't
possible; you should check the returned range and abandon the change
in this case.
In actually making changes to the text, you must ensure that
the changes are properly performed and recorded by different parts
of the text system. You do this by bracketing each batch of potential
changes with shouldChangeTextInRange:replacementString: and didChangeText messages.
These methods ensure that the appropriate delegate messages are
sent and notifications posted. The first method asks the delegate
for permission to begin editing with a textShouldBeginEditing: message.
If the delegate returns NO
, shouldChangeTextInRange:replacementString: in
turn returns NO
, in which case your subclass
should disallow the change. If the delegate returns YES
,
the text view posts an NSTextDidBeginEditingNotification, and shouldChangeTextInRange:replacementString: in
turn returns YES
. In this case you
can make your changes to the text, and follow up by invoking didChangeText. This
method concludes the changes by posting an NSTextDidChangeNotification, which
results in the delegate receiving a textDidChange: message.
The textShouldBeginEditing: and textDidBeginEditing: messages are sent only once during an editing session. More precisely, they're sent upon the first user input since the NSTextView became the first responder. Thereafter, these messages-and the NSTextDidBeginEditingNotification-are skipped in the sequence. textView:shouldChangeTextInRange:replacementString:, however, must be invoked for each individual change.
NSTextView defines several methods to aid in "smart" insertion and deletion of text, so that spacing and punctuation is preserved after a change. Smart insertion and deletion typically applies when the user has selected whole words or other significant units of text. A smart deletion of a word before a comma, for example, also deletes the space that would otherwise be left before the comma (though not placing it on the pasteboard in a Cut operation). A smart insertion of a word between another word and a comma adds a space between the two words to protect that boundary. NSTextView automatically uses smart insertion and deletion by default; you can turn this behavior off using setSmartInsertDeleteEnabled:. Doing so causes only the selected text to be deleted, and inserted text to be added with no addition of white space.
If your subclass of NSTextView defines any methods that insert or delete text, you can make them smart by taking advantage of two NSTextView methods. smartDeleteRangeForProposedRange: expands a proposed deletion range to include any whitespace that should also be deleted. If you need to save the text deleted, though, it's typically best to save only the text from the original range. For smart insertion, smartInsertForString:replacingRange:beforeString:afterString: returns by reference two strings that you can insert before and after a given string to preserve spacing and punctuation. See the method descriptions for more information.
These constants specify how much the text view extends the selection when the user drags the mouse. They're used by selectionGranularity and setSelectionGranularity:
Constant | Description |
NSSelectByCharacter |
Extend the selection character by character |
NSSelectByWord |
Extend the selection word by word |
NSSelectByParagraph |
Extend the selection paragraph by paragraph |
These constants specify the preferred direction of selection. They're used by selectionAffinity.
Constant | Description |
NSSelectionAffinityUpstream |
Description forthcoming. |
NSSelectionAffinityDownstream |
Description forthcoming. |
NSTextInput
- - conversationIdentifier
- - doCommandBySelector:
- - getMarkedText:selectedRange:
- - hasMarkedText
- - insertText:
- - setMarkedText:selectedRange:
- - unmarkText
- Creating an instance
- - initWithFrame:textContainer:
- - initWithFrame:
- Registering Services information
- + registerForServices
- Accessing related text-system objects
- - setTextContainer:
- - replaceTextContainer:
- - textContainer
- - setTextContainerInset:
- - textContainerInset
- - textContainerOrigin
- - invalidateTextContainerOrigin
- - layoutManager
- - textStorage
- Setting graphic attributes
- - setBackgroundColor:
- - backgroundColor
- - setDrawsBackground:
- - drawsBackground
- Controlling display
- - setNeedsDisplayInRect:avoidAdditionalLayout:
- - shouldDrawInsertionPoint
- - drawInsertionPointInRect:color:turnedOn:
- - setConstrainedFrameSize:
- - cleanUpAfterDragOperation
- Setting behavioral attributes
- - allowsUndo
- - setAllowsUndo:
- - setEditable:
- - isEditable
- - setSelectable:
- - isSelectable
- - setFieldEditor:
- - isFieldEditor
- - setRichText:
- - isRichText
- - setImportsGraphics:
- - importsGraphics
- Using the Font Panel and menu
- - setUsesFontPanel:
- - usesFontPanel
- Using the ruler
- - setUsesRuler:
- - usesRuler
- - setRulerVisible:
- - isRulerVisible
- Managing the selection
- - setSelectedRange:
- - setSelectedRange:affinity:stillSelecting:
- - selectionAffinity
- - setSelectionGranularity:
- - selectionGranularity
- - setInsertionPointColor:
- - insertionPointColor
- - updateInsertionPointStateAndRestartTimer:
- - setSelectedTextAttributes:
- - selectedTextAttributes
- - setMarkedTextAttributes:
- - markedTextAttributes
- Managing the pasteboard
- - preferredPasteboardTypeFromArray:restrictedToTypesFromArray:
- - readSelectionFromPasteboard:
- - readSelectionFromPasteboard:type:
- - readablePasteboardTypes
- - writablePasteboardTypes
- - writeSelectionToPasteboard:type:
- - writeSelectionToPasteboard:types:
- Setting text attributes
- - alignJustified:
- - changeColor:
- - setAlignment:range:
- - setTypingAttributes:
- - typingAttributes
- - useStandardKerning:
- - lowerBaseline:
- - raiseBaseline:
- - turnOffKerning:
- - loosenKerning:
- - tightenKerning:
- - useStandardLigatures:
- - turnOffLigatures:
- - useAllLigatures:
- Other action methods
- - allowsUndo
- - clickedOnLink:atIndex:
- - pasteAsPlainText:
- - pasteAsRichText:
- Methods that subclasses should use or override
- - updateFontPanel
- - updateRuler
- - acceptableDragTypes
- - updateDragTypeRegistration
- - selectionRangeForProposedRange:granularity:
- - rangeForUserCharacterAttributeChange
- - rangeForUserParagraphAttributeChange
- - rangeForUserTextChange
- - shouldChangeTextInRange:replacementString:
- - didChangeText
- - setSmartInsertDeleteEnabled:
- - smartInsertDeleteEnabled
- - smartDeleteRangeForProposedRange:
- - smartInsertForString:replacingRange:beforeString:afterString:
- Changing first responder status
- - resignFirstResponder
- - becomeFirstResponder
- - validRequestorForSendType:returnType:
- Working with the spelling checker
- - spellCheckerDocumentTag
- NSRulerView client methods
- - rulerView:didMoveMarker:
- - rulerView:didRemoveMarker:
- - rulerView:didAddMarker:
- - rulerView:shouldMoveMarker:
- - rulerView:shouldAddMarker:
- - rulerView:willMoveMarker:toLocation:
- - rulerView:shouldRemoveMarker:
- - rulerView:willAddMarker:atLocation:
- - rulerView:handleMouseDown:
- Assigning a delegate
- - setDelegate:
- - delegate
+ (void)registerForServices
- (NSArray *)acceptableDragTypes
See Also: - updateDragTypeRegistration
- (void)alignJustified:(id)sender
See Also: - alignCenter: (NSText), - alignLeft: (NSText), - alignRight: (NSText), - alignment (NSText), - setAlignment: (NSText)
- (BOOL)allowsUndo
- (NSColor *)backgroundColor
See Also: - drawsBackground, - setBackgroundColor:
- (BOOL)becomeFirstResponder
YES
.Use NSWindow's makeFirstResponder:, not this method, to make an NSTextView the first responder. Never invoke this method directly.
See Also: - resignFirstResponder
- (void)changeColor:(id)sender
- (void)cleanUpAfterDragOperation
super
's
implementation.- (void)clickedOnLink:(id)link
atIndex:(unsigned)charIndex
See Also: - textView:clickedOnLink:atIndex: (delegate method)
- (id)delegate
nil
if there is none.See Also: - setDelegate:
- (void)didChangeText
See Also: - shouldChangeTextInRange:replacementString:
- (unsigned int)dragOperationForDraggingInfo:(id
<NSDraggingInfo>)dragInfo
type:(NSString *)type
Option | Meaning |
NSDragOperationCopy |
The data represented by the image will be copied. |
NSDragOperationLink |
The data will be shared. |
NSDragOperationGeneric |
The operation will be defined by the destination. |
NSDragOperationPrivate |
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.
See Also: - draggingEntered: (NSDraggingDestination), - draggingUpdated: (NSDraggingDestination)
- (void)drawInsertionPointInRect:(NSRect)aRect
color:(NSColor *)aColor
turnedOn:(BOOL)flag
YES
,
draws the insertion point in aRect using aColor.
If flag is NO
,
this method erases the insertion point. The focus must be locked
on the receiver when this method is invoked.See Also: - insertionPointColor, - shouldDrawInsertionPoint, - backgroundColor, - lockFocus (NSView)
- (BOOL)drawsBackground
YES
if
the receiver draws its background, NO
if
it doesn't.See Also: - backgroundColor, - setDrawsBackground:
- (BOOL)importsGraphics
YES
if
the text views sharing the receiver's NSLayoutManager allow the
user to import files by dragging, NO
if
they don't.A text view that accepts dragged files is also a rich text view.
See Also: - isRichText, - textStorage, + attributedStringWithAttachment: (NSAttributedString Additions), - insertAttributedString:atIndex: (NSMutableAttributedString), - setImportsGraphics:
- (id)initWithFrame:(NSRect)frameRect
This method creates the text web in such a manner that the NSTextView object is the principal owner of the objects in the web.
- (id)initWithFrame:(NSRect)frameRect
textContainer:(NSTextContainer
*)aTextContainer
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-an NSTextStorage object, an NSLayoutManager object, and an NSTextContainer object. Assembling the components in this fashion means that the NSTextStorage, not the NSTextView, is the principal owner of the component objects.
See Also: - initWithFrame:
- (void)insertText:(id)aString
This method is the means by which typed text enters an NSTextView. See the NSInputManager class and NSTextInput protocol specifications for more information.
See Also: - typingAttributes
- (NSColor *)insertionPointColor
See Also: - drawInsertionPointInRect:color:turnedOn:, - shouldDrawInsertionPoint, - setInsertionPointColor:
- (void)invalidateTextContainerOrigin
See Also: - textContainer, - textContainerOrigin
- (BOOL)isEditable
YES
if
the text views sharing the receiver's NSLayoutManager allow the
user to edit text, NO
if they don't. If
a text view is editable, it's also selectable.See Also: - isSelectable, - setEditable:
- (BOOL)isFieldEditor
YES
if
the text views sharing the receiver's NSLayoutManager interpret
Tab, Shift-Tab, and Return (Enter) as cues to end editing, and possibly
to change the first responder; no if they accept them as text input. See
the NSWindow class specification for more information on field editors.
By default, NSTextViews don't behave as field editors.See Also: - setFieldEditor:
- (BOOL)isRichText
YES
if
the text views sharing the receiver's NSLayoutManager allow the
user to apply attributes to specific ranges of the text, NO
if
they don't.See Also: - importsGraphics, - textStorage, - setRichText:
- (BOOL)isRulerVisible
YES
if
the scroll view enclosing the text views sharing the receiver's
NSLayoutManager shows its ruler, NO
otherwise.See Also: - usesRuler, - setRulerVisible:, - toggleRuler: (NSText)
- (BOOL)isSelectable
YES
if
the text views sharing the receiver's NSLayoutManager allow the
user to select text, NO
if they don't.See Also: - isEditable, - setSelectable:
- (NSLayoutManager *)layoutManager
nil
if
there's no such object (which is the case when a text view isn't
linked into a group of text objects).See Also: - textContainer, - setLayoutManager: (NSTextContainer), - replaceLayoutManager: (NSTextContainer)
- (void)loosenKerning:(id)sender
See Also: - tightenKerning:, - turnOffKerning:, - useStandardKerning:
- (void)lowerBaseline:(id)sender
See Also: - raiseBaseline:, - subscript: (NSText), - unscript: (NSText)
- (NSDictionary *)markedTextAttributes
See Also: - setMarkedTextAttributes:
- (void)pasteAsPlainText:(id)sender
See Also: - pasteAsRichText:, - insertText:
- (void)pasteAsRichText:(id)sender
See Also: - pasteAsRichText:, - insertText:
- (NSString *)preferredPasteboardTypeFromArray:(NSArray
*)availableTypes
restrictedToTypesFromArray:(NSArray
*)allowedTypes
nil
then only types in that array
may be returned; otherwise, if allowedTypes is nil
,
any of the available pasteboard types may be returned.You should not need to override this method. You should also not need to invoke it unless you were implementing a new type of pasteboard to handle services other than copy/paste or dragging.
See Also: - pasteAsPlainText:, - pasteAsRichText:
- (void)raiseBaseline:(id)sender
See Also: - lowerBaseline:, - superscript: (NSText), - unscript: (NSText)
- (NSRange)rangeForUserCharacterAttributeChange
If the receiver
isn't editable or doesn't use the Font Panel, the range returned
has a location of NSNotFound
.
See Also: - rangeForUserParagraphAttributeChange, - rangeForUserTextChange, - isEditable, - usesFontPanel
- (NSRange)rangeForUserParagraphAttributeChange
If the receiver isn't editable
the range returned has a location of NSNotFound
.
See Also: - rangeForUserParagraphAttributeChange, - rangeForUserTextChange, - isEditable, - usesRuler
- (NSRange)rangeForUserTextChange
If the receiver isn't
editable or doesn't use a ruler, the range returned has a location
of NSNotFound
.
See Also: - rangeForUserParagraphAttributeChange, - rangeForUserTextChange, - isEditable, - usesRuler
- (NSArray *)readablePasteboardTypes
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.
See Also: - preferredPasteboardTypeFromArray:restrictedToTypesFromArray:, - writablePasteboardTypes
- (BOOL)readSelectionFromPasteboard:(NSPasteboard
*)pboard
YES
if the data was successfully
read.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.
See Also: - preferredPasteboardTypeFromArray:restrictedToTypesFromArray:, - readSelectionFromPasteboard:type:
- (BOOL)readSelectionFromPasteboard:(NSPasteboard
*)pboard
type:(NSString *)type
YES
if
the data was successfully read.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.
See Also: - rangeForUserTextChange
- (void)replaceTextContainer:(NSTextContainer
*)aTextContainer
nil
.See Also: - initWithFrame:textContainer:, - setTextContainer:
- (BOOL)resignFirstResponder
YES
with
no further action. Otherwise, this method sends a textShouldEndEditing: message to
its delegate (if any). If the delegate returns NO
, this
method returns NO
. If the delegate
returns YES
this method hides the
selection highlighting and posts an NSTextDidEndEditingNotification
to the default notification center.Use NSWindow's makeFirstResponder:, not this method, to make an NSTextView the first responder. Never invoke this method directly.
See Also: - becomeFirstResponder
- (void)rulerView:(NSRulerView
*)aRulerView
didAddMarker:(NSRulerMarker *)aMarker
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.
See Also: - representedObject (NSRulerMarker), - rulerView:didMoveMarker:, - rulerView:didRemoveMarker:
- (void)rulerView:(NSRulerView
*)aRulerView
didMoveMarker:(NSRulerMarker *)aMarker
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.
See Also: - representedObject (NSRulerMarker), - rulerView:didAddMarker:, - rulerView:didRemoveMarker:
- (void)rulerView:(NSRulerView
*)aRulerView
didRemoveMarker:(NSRulerMarker
*)aMarker
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.
See Also: - representedObject (NSRulerMarker), - shouldChangeTextInRange:replacementString:, - rulerView:didAddMarker:, - rulerView:didMoveMarker:
- (void)rulerView:(NSRulerView
*)aRulerView
handleMouseDown:(NSEvent *)theEvent
- (BOOL)rulerView:(NSRulerView
*)aRulerView
shouldAddMarker:(NSRulerMarker
*)aMarker
See Also: - rulerView:shouldMoveMarker:, - rulerView:shouldRemoveMarker:
- (BOOL)rulerView:(NSRulerView
*)aRulerView
shouldMoveMarker:(NSRulerMarker
*)aMarker
See Also: - rulerView:shouldAddMarker:, - rulerView:shouldRemoveMarker:
- (BOOL)rulerView:(NSRulerView
*)aRulerView
shouldRemoveMarker:(NSRulerMarker
*)aMarker
YES
if aMarker represents
an NSTextTab, 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 allows
and the user actually removes the marker, the receiver is also sent
a rulerView:didRemoveMarker: message.See Also: - rulerView:shouldAddMarker:, - rulerView:shouldMoveMarker:
- (float)rulerView:(NSRulerView
*)aRulerView
willAddMarker:(NSRulerMarker *)aMarker
atLocation:(float)location
See Also: - rulerView:didAddMarker:
- (float)rulerView:(NSRulerView
*)aRulerView
willMoveMarker:(NSRulerMarker
*)aMarker
toLocation:(float)location
See Also: - rulerView:didMoveMarker:
- (NSDictionary *)selectedTextAttributes
See Also: - selectedRange, - setSelectedTextAttributes:
- (NSSelectionAffinity)selectionAffinity
NSSelectionAffinityUpstream
or NSSelectionAffinityDownstream
. 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.See Also: - setSelectedRange:affinity:stillSelecting:
- (NSSelectionGranularity)selectionGranularity
NSSelectByCharacter
NSSelectByWord
NSSelectByParagraph
See Also: - selectionRangeForProposedRange:granularity:, - setSelectionGranularity:
- (NSRange)selectionRangeForProposedRange:(NSRange)proposedSelRange
granularity:(NSSelectionGranularity)granularity
NSSelectByCharacter
NSSelectByWord
NSSelectByParagraph
Returns the adjusted range. This method is invoked repeatedly during mouse tracking to modify the range of the selection. Override this method to specialize selection behavior.
See Also: - setSelectionGranularity:
- (void)setAlignment:(NSTextAlignment)alignment
range:(NSRange)aRange
NSLeftTextAlignment
NSRightTextAlignment
NSCenterTextAlignment
NSJustifiedTextAlignment
NSNaturalTextAlignment
See Also: - rangeForUserParagraphAttributeChange
- (void)setAllowsUndo:(BOOL)flag
- (void)setBackgroundColor:(NSColor
*)aColor
See Also: - setDrawsBackground:, - backgroundColor
- (void)setConstrainedFrameSize:(NSSize)desiredSize
See Also: - minSize (NSText), - maxSize (NSText), - isHorizontallyResizable (NSText), - isVerticallyResizable (NSText)
- (void)setDelegate:(id)anObject
See Also: - delegate
- (void)setDrawsBackground:(BOOL)flag
YES
,
the receiver fills its background with the background color; if flag is NO
,
it doesn't.See Also: - setBackgroundColor:, - drawsBackground
- (void)setEditable:(BOOL)flag
YES
,
they allow the user to edit text and attributes; if flag is NO
,
they don't. If an NSTextView is made editable, it's also made
selectable. NSTextViews are by default editable.See Also: - setSelectable:, - isEditable
- (void)setFieldEditor:(BOOL)flag
YES
, they
do; if flag is NO
,
they don't, instead accepting these characters as text input.
See the NSWindow class specification for more information on field
editors. By default, NSTextViews don't behave as field editors.See Also: - isFieldEditor
- (void)setImportsGraphics:(BOOL)flag
YES
,
they do; if flag is NO
,
they don't. If an NSTextView is set to accept dragged files, it's
also set for rich text. By default, NSTextViews don't accept dragged
files.See Also: - textStorage, - setRichText:, - importsGraphics
- (void)setInsertionPointColor:(NSColor
*)aColor
See Also: - drawInsertionPointInRect:color:turnedOn:, - shouldDrawInsertionPoint, - insertionPointColor
- (void)setMarkedTextAttributes:(NSDictionary
*)attributes
See Also: - markedTextAttributes, - markedRange
- (void)setNeedsDisplayInRect:(NSRect)aRect
avoidAdditionalLayout:(BOOL)flag
YES
,
the receiver won't perform any layout that might be required to
complete the display, even if this means that portions of the NSTextView
remain empty. If flag is NO
,
the receiver performs at least as much layout as needed to display aRect.NSTextView
overrides the NSView setNeedsDisplayInRect: method such
that it invokes this method with a flag argument
of NO
.
- (void)setRichText:(BOOL)flag
YES
they
do; if flag is NO
they
don't. If flag is NO
,
they're also set not to accept dragged files. By default, NSTextViews
let the user apply multiple attributes to text, but don't accept
dragged files.See Also: - textStorage, - isRichText, - setImportsGraphics:
- (void)setRulerVisible:(BOOL)flag
YES
it
shows the ruler; if flag is NO
it
hides the ruler. By default, the ruler is not visible.See Also: - setUsesRuler:, - isRulerVisible, - toggleRuler: (NSText)
- (void)setSelectable:(BOOL)flag
NO
,
they do; if flag is NO
,
they don't. If an NSTextView is made not selectable, it's also
made not editable. NSTextViews are by default both editable and
selectable.See Also: - setEditable:, - isSelectable
- (void)setSelectedRange:(NSRange)charRange
NSSelectByCharacter
,
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.charRange must begin and end on glyph boundaries and not split base glyphs and their non-spacing marks.
See Also: - setSelectedRange:affinity:stillSelecting:, - selectionAffinity, - selectionGranularity, - selectedRange
- (void)setSelectedRange:(NSRange)charRange
affinity:(NSSelectionAffinity)affinity
stillSelecting:(BOOL)flag
YES
the
receiver doesn't send notifications or remove the marking from
its marked text; if flag is NO
it
does as appropriate. This method also resets the selection granularity
to NSSelectByCharacter
.charRange must begin and end on glyph boundaries and not split base glyphs and their non-spacing marks.
See Also: - setSelectedRange:, - selectionAffinity, - selectionGranularity, - setSelectedRange:
- (void)setSelectedTextAttributes:(NSDictionary
*)attributes
See Also: - selectedRange, - selectedTextAttributes
- (void)setSelectionGranularity:(NSSelectionGranularity)granularity
NSSelectByCharacter
NSSelectByWord
NSSelectByParagraph
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.
See Also: - selectionGranularity, - setSelectedRange:
- (void)setSmartInsertDeleteEnabled:(BOOL)flag
YES
it
does; if flag is NO
it
inserts and deletes exactly what's selected.See Also: - smartInsertForString:replacingRange:beforeString:afterString:, - smartDeleteRangeForProposedRange:, - smartInsertDeleteEnabled
public void setTextContainer(NSTextContainer aTextContainer)
See Also: - textContainer
- (void)setTextContainerInset:(NSSize)inset
See Also: - textContainerOrigin, - invalidateTextContainerOrigin, - textContainerInset
- (void)setTypingAttributes:(NSDictionary
*)attributes
See Also: - typingAttributes
- (void)setUsesFontPanel:(BOOL)flag
YES
,
they respond to messages from the Font Panel and from the Font menu,
and update the Font Panel with the selection font whenever it changes.
If flag is NO
they
disallow character attribute changes. By default, NSTextView objects
use the Font Panel and menu.See Also: - rangeForUserCharacterAttributeChange, - usesFontPanel
- (void)setUsesRuler:(BOOL)flag
YES
,
they respond to NSRulerView client messages and to paragraph-related
menu actions, and update the ruler (when visible) as the selection
changes with its paragraph and tab attributes. If flag is NO
,
the ruler is hidden and the text views disallow paragraph attribute
changes. By default, NSTextView objects use the ruler.See Also: - setRulerVisible:, - rangeForUserParagraphAttributeChange, - usesRuler
- (BOOL)shouldChangeTextInRange:(NSRange)affectedCharRange
replacementString:(NSString *)replacementString
nil
.
This method checks with the delegate as needed using textShouldBeginEditing: and textView:shouldChangeTextInRange:replacementString:,
returning YES
to allow the change,
and NO
to prohibit it.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.
See "Notifying About Changes to the Text" in the class description
for more information. If you can't determine the affected range
or replacement string before beginning changes, pass (NSNotFound
,
0) and nil
for these values.
See Also: - isEditable
- (BOOL)shouldDrawInsertionPoint
YES
if
the receiver should draw its insertion point, NO
if
the insertion point can't or shouldn't be drawn. For
example, you might not want to draw the insertion point if the receiver's window
isn't key).See Also: - drawInsertionPointInRect:color:turnedOn:
- (NSRange)smartDeleteRangeForProposedRange:(NSRange)proposedCharRange
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.
See Also: - smartInsertForString:replacingRange:beforeString:afterString:, - selectionGranularity, - smartInsertDeleteEnabled
- (NSString *)smartInsertAfterStringForString:(NSString
*)aString
replacingRange:(NSRange)charRange
nil
or if
smart insertion and deletion is disabled, this method returns nil
.Don't invoke this method directly. Instead, use smartInsertForString:replacingRange:beforeString:afterString:, which calls this method as part of its implementation.
- (NSString *)smartInsertBeforeStringForString:(NSString
*)aString
replacingRange:(NSRange)charRange
nil
or if
smart insertion and deletion is disabled, this method returns nil
.Don't invoke this method directly. Instead, use smartInsertForString:replacingRange:beforeString:afterString:, which calls this method as part of its implementation.
- (BOOL)smartInsertDeleteEnabled
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.See Also: - smartInsertForString:replacingRange:beforeString:afterString:, - smartDeleteRangeForProposedRange:, - setSmartInsertDeleteEnabled:
- (void)smartInsertForString:(NSString
*)aString
replacingRange:(NSRange)charRange
beforeString:(NSString **)beforeString
afterString:(NSString **)afterString
nil
. Both
are returned as nil
if aString is nil
or
if smart insertion and deletion is disabled.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.
See Also: - smartDeleteRangeForProposedRange:, - smartInsertDeleteEnabled
- (int)spellCheckerDocumentTag
- (NSTextContainer *)textContainer
See Also: - setTextContainer:
- (NSSize)textContainerInset
See Also: - textContainerOrigin, - invalidateTextContainerOrigin, - setTextContainerInset:
- (NSPoint)textContainerOrigin
See Also: - invalidateTextContainerOrigin, - textContainerInset, - usedRectForTextContainer: (NSLayoutManager)
- (NSTextStorage *)textStorage
- (void)tightenKerning:(id)sender
See Also: - loosenKerning:, - useStandardKerning:, - turnOffKerning:
- (void)turnOffKerning:(id)sender
See Also: - useStandardKerning:, - loosenKerning:, - tightenKerning:, - isRichText
- (void)turnOffLigatures:(id)sender
See Also: - useAllLigatures:, - isRichText, - useStandardLigatures:
- (NSDictionary *)typingAttributes
See Also: - setTypingAttributes:
- (void)updateDragTypeRegistration
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 NSTextView. They can then invoke this method when that state changes to perform that reregistration.
See Also: - acceptableDragTypes, - registerForDraggedTypes: (NSView), - unregisterDraggedTypes (NSView), - isEditable, - importsGraphics, - isRichText
- (void)updateFontPanel
See Also: - usesFontPanel
- (void)updateInsertionPointStateAndRestartTimer:(BOOL)flag
YES
,
restarts the blinking cursor timer. 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 add different insertion point behavior.See Also: - shouldDrawInsertionPoint, - drawInsertionPointInRect:color:turnedOn:
- (void)updateRuler
See Also: - usesRuler
- (void)useAllLigatures:(id)sender
See Also: - turnOffLigatures:, - useStandardLigatures:
- (void)useStandardKerning:(id)sender
See Also: - isRichText, - loosenKerning:, - tightenKerning:, - turnOffKerning:
- (void)useStandardLigatures:(id)sender
See Also: - turnOffLigatures:, - useAllLigatures:
- (BOOL)usesFontPanel
YES
if
the text views sharing the receiver's NSLayoutManager use the
Font Panel, NO
otherwise. See setUsesFontPanel: and rangeForUserCharacterAttributeChange for
the effect this has on an NSTextView's behavior.- (BOOL)usesRuler
YES
if
the text views sharing the receiver's NSLayoutManager use a ruler
view, NO
otherwise. See setUsesRuler: and rangeForUserParagraphAttributeChange for
the effect this has on an NSTextView's behaviorSee Also: - setUsesRuler:
- (id)validRequestorForSendType:(NSString
*)sendType
returnType:(NSString *)returnType
nil
.See Also: - validRequestorForSendType:returnType: (NSResponder)
- (NSArray *)writablePasteboardTypes
See Also: - readablePasteboardTypes
- (BOOL)writeSelectionToPasteboard:(NSPasteboard
*)pboard
type:(NSString *)type
YES
if
the data was successfully written. 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.See Also: - readSelectionFromPasteboard:type:
- (BOOL)writeSelectionToPasteboard:(NSPasteboard
*)pboard
types:(NSArray *)types
YES
if
the data for any single type was written successfully.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.
See Also: - writeSelectionToPasteboard:type:
NSTextView communicates with its delegate through methods declared both by NSTextView and by its superclass, NSText. See the NSText class specification for those other delegate methods.
- (void)textView:(NSTextView
*)aTextView
clickedOnCell:(id <NSTextAttachmentCell>)attachmentCell
inRect:(NSRect)cellFrame
The delegate may subsequently receive a textView:doubleClickedOnCell:inRect: message if the user continues to perform a double click.
This method is being deprecated in favor of textView:clickedOnCell:inRect:atIndex:.
See Also: - wantsToTrackMouse (NSTextAttachmentCell)
- (void)textView:(NSTextView
*)textView
clickedOnCell:(id <NSTextAttachmentCell>)cell
inRect:(NSRect)cellFrame
atIndex:(unsigned)charIndex
The delegate may subsequently receive a textView:doubleClickedOnCell:inRect:atIndex: message if the user continues to perform a double click.
See Also: - textView:doubleClickedOnCell:inRect:atIndex:
- (BOOL)textView:(NSTextView
*)textView
clickedOnLink:(id)link
This method is being deprecated in favor of textView:clickedOnLink:atIndex:.
See Also: - clickedOnLink:atIndex: (NSTextView), - textView:clickedOnLink:atIndex:
- (BOOL)textView:(NSTextView
*)textView
clickedOnLink:(id)link
atIndex:(unsigned)charIndex
YES
to
indicate that the click was handled, otherwise return NO
to
allow the next responder to handle it.See Also: - clickedOnLink:atIndex: (NSTextView)
- (void)textViewDidChangeSelection:(NSNotification
*)aNotification
See Also: NSTextViewDidChangeSelectionNotification (notification)
- (BOOL)textView:(NSTextView
*)aTextView
doCommandBySelector:(SEL)aSelector
YES
,
the text view doesn't perform aSelector;
if the delegate returns NO
, the text
view attempts to perform it. aTextView is
the first NSTextView in a series shared by an NSLayoutManager.- (void)textView:(NSTextView
*)aTextView
doubleClickedOnCell:(id <NSTextAttachmentCell>)attachmentCell
inRect:(NSRect)cellFrame
This method is being deprecated in favor of textView:doubleClickedOnCell:inRect:atIndex:.
See Also: - wantsToTrackMouse (NSTextAttachmentCell), - textView:doubleClickedOnCell:inRect:atIndex:
- (void)textView:(NSTextView
*)textView
doubleClickedOnCell:(id <NSTextAttachmentCell>)cell
inRect:(NSRect)cellFrame
atIndex:(unsigned)charIndex
See Also: - wantsToTrackMouse (NSTextAttachmentCell)
- (void)textView:(NSTextView
*)aTextView
draggedCell:(id <NSTextAttachmentCell>)attachmentCell
inRect:(NSRect)aRect
event:(NSEvent *)theEvent
This method is being deprecated in favor of textView:draggedCell:inRect:event:atIndex:.
See Also: - wantsToTrackMouse (NSTextAttachmentCell), - dragImage:at:offset:event:pasteboard:source:slideBack: (NSView), - dragFile:fromRect:slideBack:event: (NSView)
- (void)textView:(NSTextView
*)view
draggedCell:(id <NSTextAttachmentCell>)cell
inRect:(NSRect)rect
event:(NSEvent *)event
atIndex:(unsigned)charIndex
See Also: - wantsToTrackMouse (NSTextAttachmentCell), - dragImage:at:offset:event:pasteboard:source:slideBack: (NSView), - dragFile:fromRect:slideBack:event: (NSView)
- (BOOL)textView:(NSTextView
*)aTextView
shouldChangeTextInRange:(NSRange)affectedCharRange
replacementString:(NSString *)replacementString
nil
.
The delegate can return YES
to allow
the replacement, or NO
to reject
the change.aTextView is the first NSTextView in a series shared by an NSLayoutManager.
- (NSRange)textView:(NSTextView
*)aTextView
willChangeSelectionFromCharacterRange:(NSRange)oldSelectedCharRange
toCharacterRange:(NSRange)newSelectedCharRange
NO
. oldSelectedCharRange is
the original range of the selection. newSelectedCharRange is
the proposed character range for the new selection. The delegate
can return an adjusted range or return newSelectedCharRange unmodified.aTextView is the first NSTextView in a series shared by an NSLayoutManager.
- (NSUndoManager *)undoManagerForTextView:(NSTextView
*)view
NSTextView posts the following notifications as well as those declared by its superclasses, particularly NSText. See the NSText class specification for those other notifications.
This notification contains a notification object and a userInfo dictionary. The notification object is the notifying NSTextView. The userInfo dictionary contains these keys and values:
Key | Value |
NSOldSelectedCharacterRange |
An NSValue object containing an NSRange |
This notification contains
a notification object and a userInfo dictionary.
The notification object is the old notifying NSTextView, or nil
.
The userInfo dictionary contains
these keys and values:
Key | Value |
NSOldNotifyingTextView |
The old NSTextView, if one exists |
NSNewNotifyingTextView |
The new NSTextView, if one exists |
There's no delegate method associated with this notification. The text-handling system ensures that when a new NSTextView replaces an old one as the notifying NSTextView, the existing delegate becomes the delegate of the new NSTextView and the delegate is registered to receive NSTextView notifications from the new notifying NSTextView. All other observers are responsible for registering themselves on receiving this notification.
See Also: - removeObserver: (NSNotificationCenter), - addObserver:selector:name:object: (NSNotificationCenter)