NSText Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in OS X v10.0 and later. |
| Companion guide | |
| Declared in | NSText.h |
Class at a Glance
NSText declares the most general programmatic interface for objects that manage text. You usually use instances of its subclass, NSTextView.
Principal Attributes
Draws text for user interface objects
Uses a delegate
Provides text editing capabilities
Controls text attributes such as type size, font, and color
Commonly Used Methods
readRTFDFromFile:Reads an
.rtfor.rtfdfile.writeRTFDToFile:atomically:Writes the receiver’s text to a file.
stringReturns the receiver’s text without attributes.
RTFFromRange:Returns the receiver’s text with attributes.
RTFDFromRange:Returns the receiver’s text with attributes and attachments.
Overview
NSText declares the most general programmatic interface for objects that manage text. You usually use instances of its subclass, NSTextView.
NSTextView extends the interface declared by NSText and provides much more sophisticated functionality than that declared in NSText.
NSText initialization creates an instance of a concrete subclass, such as NSTextView. Instances of any of these classes are generically called text objects.
Text objects are used by the Application Kit wherever text appears in interface objects: A text object draws the title of a window, the commands in a menu, the title of a button, and the items in a browser. Your application can also create text objects for its own purposes.
Adopted Protocols
Tasks
Getting the Characters
Setting Graphics Attributes
Setting Behavioral Attributes
-
– setEditable: -
– isEditable -
– setSelectable: -
– isSelectable -
– setFieldEditor: -
– isFieldEditor -
– setRichText: -
– isRichText -
– setImportsGraphics: -
– importsGraphics
Using the Font Panel and Menu
Using the Ruler
Changing the Selection
Replacing Text
-
– replaceCharactersInRange:withRTF: -
– replaceCharactersInRange:withRTFD: -
– replaceCharactersInRange:withString: -
– setString:
Action Methods for Editing
Changing the Font
Setting Text Alignment
Setting Text Color
Writing Direction
Setting Superscripting and Subscripting
Underlining Text
Reading and Writing RTF Files
Checking Spelling
Constraining Size
-
– setMaxSize: -
– maxSize -
– setMinSize: -
– minSize -
– setVerticallyResizable: -
– isVerticallyResizable -
– setHorizontallyResizable: -
– isHorizontallyResizable -
– sizeToFit
Scrolling
Setting the Delegate
Instance Methods
alignCenter:
This action method applies center alignment to selected paragraphs (or all text if the receiver is a plain text object).
Availability
- Available in OS X v10.0 and later.
Declared In
NSText.halignLeft:
This action method applies left alignment to selected paragraphs (or all text if the receiver is a plain text object).
Availability
- Available in OS X v10.0 and later.
Declared In
NSText.halignment
Returns the alignment of the first paragraph (or all text if the receiver is a plain text object).
Discussion
The returned value is one of the alignments described in “NSTextAlignment.”
Text using NSNaturalTextAlignment is actually displayed using one of the other alignments, depending on the natural alignment of the text’s script.
Availability
- Available in OS X v10.0 and later.
Declared In
NSText.halignRight:
This action method applies right alignment to selected paragraphs (or all text if the receiver is a plain text object).
Availability
- Available in OS X v10.0 and later.
Declared In
NSText.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
NSText.hbaseWritingDirection
Returns the initial writing direction used to determine the actual writing direction for text.
Discussion
The Text system uses this value as a hint for calculating the actual direction for displaying Unicode characters. You should not need to call this method directly. If no writing direction is set, returns NSWritingDirectionNatural.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSText.hchangeFont:
This action method changes the font of the selection for a rich text object, or of all text for a plain text object.
Discussion
If the receiver doesn’t use the Font panel, this method does nothing.
This method changes the font by sending a convertFont: message to the shared NSFontManager and applying each NSFont returned to the appropriate text. See the NSFontManager class specification for more information on font conversion.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hcheckSpelling:
This action method searches for a misspelled word in the receiver’s text.
Discussion
The search starts at the end of the selection and continues until it reaches a word suspected of being misspelled or the end of the text. If a word isn’t recognized by the spelling server, a showGuessPanel: message then opens the Guess panel and allows the user to make a correction or add the word to the local dictionary.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hcopy:
This action method copies the selected text onto the general pasteboard, in as many formats as the receiver supports.
Discussion
A plain text object uses NSStringPboardType for plain text, and a rich text object also uses NSRTFPboardType.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hcopyFont:
This action method copies the font information for the first character of the selection (or for the insertion point) onto the font pasteboard, as NSFontPboardType.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hcopyRuler:
This action method copies the paragraph style information for first selected paragraph onto the ruler pasteboard, as NSRulerPboardType, and expands the selection to paragraph boundaries.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hcut:
This action method deletes the selected text and places it onto the general pasteboard, in as many formats as the receiver supports.
Discussion
A plain text object uses NSStringPboardType for plain text, and a rich text object also uses NSRTFPboardType.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hdelegate
Returns the receiver’s delegate.
Return Value
The receiver’s delegate, or nil if it has none.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hdelete:
This action method deletes the selected text.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hdrawsBackground
Returns a Boolean value that indicates whether the receiver draws its background.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hfont
Returns the font of the first character in the receiver’s text, or of the insertion point if there’s no text.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.himportsGraphics
Returns a Boolean value that indicates whether the receiver allows the user to import files by dragging.
Discussion
A text object that accepts dragged files is also a rich text object.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hisEditable
Returns a Boolean value that indicates whether the receiver allows the user to edit text, NO if it doesn’t.
Discussion
You can change the receiver’s text programmatically regardless of this setting.
If the receiver is editable, it’s also selectable.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hisFieldEditor
Returns a Boolean value that indicates whether the receiver interprets Tab, Shift-Tab, and Return (Enter) as cues to end editing and possibly to change the first responder.
Return Value
YES if the receiver interprets Tab, Shift-Tab, and Return (Enter) as cues to end editing and possibly to change the first responder; NO if it accepts them as text input.
Discussion
See the NSWindow class specification for more information on field editors. By default, NSText objects don’t behave as field editors.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hisHorizontallyResizable
Returns YES if the receiver automatically changes its width to accommodate the width of its text, NO if it doesn’t.
Discussion
By default, an NSText object is not horizontally resizable.
Availability
- Available in OS X v10.0 and later.
Declared In
NSText.hisRichText
Returns a Boolean value that indicates whether the receiver allows the user to apply attributes to specific ranges of the text.
Return Value
YES if the receiver allows the user to apply attributes to specific ranges of the text, otherwise NO.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hisRulerVisible
Returns a Boolean value that indicates whether the receiver’s enclosing scroll view shows its ruler.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hisSelectable
Returns a Boolean value that indicates whether the receiver allows the user to select text, NO if it doesn’t.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hisVerticallyResizable
Returns YES if the receiver automatically changes its height to accommodate the height of its text, NO if it doesn’t.
Discussion
By default, an NSText object is vertically resizable.
Availability
- Available in OS X v10.0 and later.
Declared In
NSText.hmaxSize
Returns the receiver’s maximum size.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hminSize
Returns the receiver’s minimum size.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hpaste:
This action method pastes text from the general pasteboard at the insertion point or over the selection.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hpasteFont:
This action method pastes font information from the font pasteboard onto the selected text or insertion point of a rich text object, or over all text of a plain text object.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hpasteRuler:
This action method pastes paragraph style information from the ruler pasteboard onto the selected paragraphs of a rich text object.
Discussion
It doesn’t apply to a plain text object.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hreadRTFDFromFile:
Attempts to read the RTFD file at path, returning YES if successful and NO if not.
Discussion
path should be the path for an .rtf file or an .rtfd file wrapper, not for the RTF file within an .rtfd file wrapper.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hreplaceCharactersInRange:withRTF:
Replaces the characters in the given range with RTF text interpreted from the given RTF data.
Parameters
- aRange
The range of characters to be replaced.
- rtfData
The RTF data from which to derive the replacement string.
Discussion
This method applies only to rich text objects.
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.
This method is designed for transferring text from out-of-process sources such as the pasteboard. In most cases, programmatic modification of the text is best done by operating on the text storage directly, using the general methods of NSMutableAttributedString.
Availability
- Available in OS X v10.0 and later.
Declared In
NSText.hreplaceCharactersInRange:withRTFD:
Replaces the characters in the given range with RTFD text interpreted from the given RTFD data.
Parameters
- aRange
The range of characters to be replaced.
- rtfdData
The RTFD data from which to derive the replacement string.
Discussion
This method applies only to rich text objects.
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.
This method is designed for transferring text from out-of-process sources such as the pasteboard. In most cases, programmatic modification of the text is best done by operating on the text storage directly, using the general methods of NSMutableAttributedString.
Availability
- Available in OS X v10.0 and later.
Declared In
NSText.hreplaceCharactersInRange:withString:
Replaces the characters in the given range with those in the given string.
Parameters
- aRange
The range of characters to be replaced.
- aString
The replacement string.
Discussion
For a rich text object, the text of aString is assigned the formatting attributes of the first character of the text it replaces, or of the character immediately before aRange if the range’s length is 0. If the range’s location is 0, the formatting attributes of the first character in the receiver are used.
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.
In most cases, programmatic modification of the text is best done by operating on the text storage directly, using the general methods of NSMutableAttributedString.
Availability
- Available in OS X v10.0 and later.
Declared In
NSText.hRTFDFromRange:
Returns an NSData object that contains an RTFD stream corresponding to the characters and attributes within aRange.
Discussion
Raises an NSRangeException if any part of aRange lies beyond the end of the receiver’s characters.
When writing data to the pasteboard, you can use the NSData object as the first argument to NSPasteboard's setData:forType: method, with a second argument of NSRTFDPboardType.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hRTFFromRange:
Returns an NSData object that contains an RTF stream corresponding to the characters and attributes within aRange, omitting any attachment characters and attributes.
Discussion
Raises an NSRangeException if any part of aRange lies beyond the end of the receiver’s characters.
When writing data to the pasteboard, you can use the NSData object as the first argument to NSPasteboard's setData:forType: method, with a second argument of NSRTFPboardType.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hscrollRangeToVisible:
Scrolls the receiver in its enclosing scroll view so the first characters of aRange are visible.
Availability
- Available in OS X v10.0 and later.
Declared In
NSText.hselectAll:
This action method selects all of the receiver’s text.
Availability
- Available in OS X v10.0 and later.
Declared In
NSText.hselectedRange
Returns the range of selected characters.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hsetAlignment:
Sets the alignment of all the receiver’s text to mode.
Discussion
The value of mode must be one of the alignments described in “NSTextAlignment.”
Text using NSNaturalTextAlignment is actually displayed using one of the other alignments, depending on the natural alignment of the text’s script.
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
NSText.hsetBackgroundColor:
Sets the receiver’s background color to a given color.
Parameters
- aColor
The background color for the receiver.
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.
See Also
Declared In
NSText.hsetBaseWritingDirection:
Sets the initial writing direction used to determine the actual writing direction for text.
Discussion
If you know the base writing direction of the text you are rendering, you can use this method to specify that direction to the text system.
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.
See Also
Declared In
NSText.hsetDelegate:
Sets the receiver’s delegate.
Parameters
- anObject
The delegate for the receiver.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hsetDrawsBackground:
Controls whether the receiver draws its background.
Parameters
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hsetEditable:
Controls whether the receiver allows the user to edit its text.
Parameters
Discussion
You can change the receiver’s text programmatically regardless of this setting. If the receiver is made editable, it’s also made selectable. NSText objects are by default editable.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hsetFieldEditor:
Controls whether the receiver interprets Tab, Shift-Tab, and Return (Enter) as cues to end editing and possibly to change the first responder.
Parameters
Discussion
See the NSWindow class specification for more information on field editors. By default, NSText objects don’t behave as field editors.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hsetFont:
Sets the font of all the receiver’s text to aFont.
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.
See Also
Declared In
NSText.hsetFont:range:
Sets the font of characters within aRange to aFont.
Discussion
This method applies only to a rich text object.
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
NSText.hsetHorizontallyResizable:
Controls whether the receiver changes its width to fit the width of its text.
Availability
- Available in OS X v10.0 and later.
Declared In
NSText.hsetImportsGraphics:
Controls whether the receiver allows the user to import files by dragging.
Parameters
Discussion
If the receiver is set to accept dragged files, it’s also made a rich text object. Subclasses may or may not accept dragged files by default.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hsetMaxSize:
Sets the receiver’s maximum size to aSize.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hsetMinSize:
Sets the receiver’s minimum size to aSize.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hsetRichText:
Controls whether the receiver allows the user to apply attributes to specific ranges of the text.
Parameters
Discussion
If flag is NO, the receiver is also set not to accept dragged files. Subclasses may or may not let the user apply multiple attributes to the text and accept drag files by default.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hsetSelectable:
Controls whether the receiver allows the user to select its text.
Parameters
Discussion
You can set selections programmatically regardless of this setting. If the receiver is made not selectable, it’s also made not editable. NSText objects are by default editable and selectable.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hsetSelectedRange:
Selects the receiver’s characters within aRange.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hsetString:
Replaces the receiver’s entire text with aString, applying the formatting attributes of the old first character to its new contents.
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
NSText.hsetTextColor:
Sets the text color of all characters in the receiver to aColor.
Discussion
Removes the text color attribute if aColor is nil.
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
NSText.hsetTextColor:range:
Sets the text color of characters within aRange to aColor.
Discussion
Removes the text color attribute if aColor is nil. This method applies only to rich text objects.
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
NSText.hsetUsesFontPanel:
Controls whether the receiver uses the Font panel and Font menu.
Parameters
Discussion
By default, an NSText object uses the Font panel and menu.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hsetVerticallyResizable:
Controls whether the receiver changes its height to fit the height of its text.
Availability
- Available in OS X v10.0 and later.
Declared In
NSText.hshowGuessPanel:
This action method opens the Spelling panel, allowing the user to make a correction during spell checking.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hsizeToFit
Resizes the receiver to fit its text.
Discussion
The text view will not be sized any smaller than its minimum size, however.
Availability
- Available in OS X v10.0 and later.
Declared In
NSText.hstring
Returns the characters of the receiver’s text.
Return Value
The characters of the receiver’s text.
Discussion
For performance reasons, this method returns the current backing store of the text object. If you want to maintain a snapshot of this as you manipulate the text storage, you should make a copy of the appropriate substring.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hsubscript:
This action method applies a subscript attribute to selected text (or all text if the receiver is a plain text object), lowering its baseline offset by a predefined amount.
Availability
- Available in OS X v10.0 and later.
See Also
-
– subscript: -
– unscript: -
lowerBaseline:(NSTextView)
Declared In
NSText.hsuperscript:
This action method applies a superscript attribute to selected text (or all text if the receiver is a plain text object), raising its baseline offset by a predefined amount.
Availability
- Available in OS X v10.0 and later.
See Also
-
– subscript: -
– unscript: -
raiseBaseline:(NSTextView)
Declared In
NSText.htextColor
Returns the color of the receiver’s first character, or for the insertion point if there’s no text.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.htoggleRuler:
This action method shows or hides the ruler, if the receiver is enclosed in a scroll view.
Availability
- Available in OS X v10.0 and later.
Declared In
NSText.hunderline:
Adds the underline attribute to the selected text attributes if absent; removes the attribute if present.
Discussion
If there is a selection and the first character of the selected range has any form of underline on it, or if there is no selection and the typing attributes have any form of underline, then underline is removed; otherwise a single simple underline is added.
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.0 and later.
Declared In
NSText.hunscript:
This action method removes any superscripting or subscripting from selected text (or all text if the receiver is a plain text object).
Availability
- Available in OS X v10.0 and later.
See Also
-
– subscript: -
– superscript: -
raiseBaseline:(NSTextView) -
lowerBaseline:(NSTextView)
Declared In
NSText.husesFontPanel
Returns a Boolean value that indicates whether the receiver uses the Font panel.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSText.hwriteRTFDToFile:atomically:
Writes the receiver’s text as RTF with attachments to a file or directory at path.
Discussion
Returns YES on success and NO on failure. If atomicFlag is YES, attempts to write the file safely so that an existing file at path is not overwritten, nor does a new file at path actually get created, unless the write is successful.
Availability
- Available in OS X v10.0 and later.
Declared In
NSText.hConstants
NSTextAlignment
These constants specify text alignment.
typedef enum _NSTextAlignment {
NSLeftTextAlignment = 0,
NSRightTextAlignment = 1,
NSCenterTextAlignment = 2,
NSJustifiedTextAlignment = 3,
NSNaturalTextAlignment = 4
} NSTextAlignment;
Constants
NSLeftTextAlignmentText is visually left aligned.
Available in OS X v10.0 and later.
Declared in
NSText.h.NSRightTextAlignmentText is visually right aligned.
Available in OS X v10.0 and later.
Declared in
NSText.h.NSCenterTextAlignmentText is visually center aligned.
Available in OS X v10.0 and later.
Declared in
NSText.h.NSJustifiedTextAlignmentText is justified.
Available in OS X v10.0 and later.
Declared in
NSText.h.NSNaturalTextAlignmentUse the natural alignment of the text’s script.
Available in OS X v10.0 and later.
Declared in
NSText.h.
Declared In
NSText.hNSWritingDirection
These constants specify the writing directions:
enum {
NSWritingDirectionNatural = -1,
NSWritingDirectionLeftToRight = 0,
NSWritingDirectionRightToLeft
};
typedef NSInteger NSWritingDirection;
Constants
NSWritingDirectionNaturalThe writing direction is determined using the Unicode Bidi Algorithm rules P2 and P3. Default.
Available in OS X v10.4 and later.
Declared in
NSText.h.NSWritingDirectionLeftToRightThe writing direction is left to right.
Available in OS X v10.2 and later.
Declared in
NSText.h.NSWritingDirectionRightToLeftThe writing direction is right to left.
Available in OS X v10.2 and later.
Declared in
NSText.h.
Additional Writing Directions
Additional values to be added to NSWritingDirectionLeftToRight or NSWritingDirectionRightToLeft, when used with NSWritingDirectionAttributeName.
enum {
NSTextWritingDirectionEmbedding = (0 << 1),
NSTextWritingDirectionOverride = (1 << 1)
};
Constants
NSTextWritingDirectionEmbeddingDirection is embedded.
Available in OS X v10.6 and later.
Declared in
NSText.h.NSTextWritingDirectionOverrideDirection override
Available in OS X v10.6 and later.
Declared in
NSText.h.
Movement Codes
These constants specify the reason for a change of editing focus among text fields, in essence answering the question “why am I leaving the field?”
enum {
NSIllegalTextMovement = 0,
NSReturnTextMovement = 0x10,
NSTabTextMovement = 0x11,
NSBacktabTextMovement = 0x12,
NSLeftTextMovement = 0x13,
NSRightTextMovement = 0x14,
NSUpTextMovement = 0x15,
NSDownTextMovement = 0x16,
NSCancelTextMovement = 0x17,
NSOtherTextMovement = 0
};
Constants
NSIllegalTextMovementCurrently unused.
Available in OS X v10.0 and later.
Declared in
NSText.h.NSReturnTextMovementThe Return key was pressed.
Available in OS X v10.0 and later.
Declared in
NSText.h.NSTabTextMovementThe Tab key was pressed.
Available in OS X v10.0 and later.
Declared in
NSText.h.NSBacktabTextMovementThe Backtab (Shift-Tab) key was pressed.
Available in OS X v10.0 and later.
Declared in
NSText.h.NSLeftTextMovementThe left arrow key was pressed.
Available in OS X v10.0 and later.
Declared in
NSText.h.NSRightTextMovementThe right arrow key was pressed.
Available in OS X v10.0 and later.
Declared in
NSText.h.NSUpTextMovementThe up arrow key was pressed.
Available in OS X v10.0 and later.
Declared in
NSText.h.NSDownTextMovementThe down arrow key was pressed.
Available in OS X v10.0 and later.
Declared in
NSText.h.NSCancelTextMovementThe user cancelled the completion.
Available in OS X v10.3 and later.
Declared in
NSText.h.NSOtherTextMovementThe user performed some undefined action.
Available in OS X v10.3 and later.
Declared in
NSText.h.
Discussion
They are the possible values for the NSTextMovement key of the NSTextDidEndEditingNotificationuserInfo dictionary. The field editor makes sure that these are the values sent when the user presses the Tab, Backtab, or Return key while editing. The control then uses this information to decide where to send focus next.
Declared In
NSText.hCommonly-used Unicode characters
These constants specify several commonly used Unicode characters.
enum {
NSParagraphSeparatorCharacter = 0x2029,
NSLineSeparatorCharacter = 0x2028,
NSTabCharacter = 0x0009,
NSFormFeedCharacter = 0x000c,
NSNewlineCharacter = 0x000a,
NSCarriageReturnCharacter = 0x000d,
NSEnterCharacter = 0x0003,
NSBackspaceCharacter = 0x0008,
NSBackTabCharacter = 0x0019,
NSDeleteCharacter = 0x007f
};
Constants
NSParagraphSeparatorCharacterThe paragraph separator character:
0x2029Available in OS X v10.0 and later.
Declared in
NSText.h.NSLineSeparatorCharacterThe line separator character:
0x2028Available in OS X v10.0 and later.
Declared in
NSText.h.NSTabCharacterThe tab character:
0x0009Available in OS X v10.0 and later.
Declared in
NSText.h.NSBackTabCharacterThe back tab character:
0x0019Available in OS X v10.0 and later.
Declared in
NSText.h.NSFormFeedCharacterThe form feed character:
0x000cAvailable in OS X v10.0 and later.
Declared in
NSText.h.NSNewlineCharacterThe newline character:
0x000aAvailable in OS X v10.0 and later.
Declared in
NSText.h.NSCarriageReturnCharacterThe carriage return character:
0x000dAvailable in OS X v10.0 and later.
Declared in
NSText.h.NSEnterCharacterThe enter character:
0x0003Available in OS X v10.0 and later.
Declared in
NSText.h.NSBackspaceCharacterThe backspace character:
0x0008Available in OS X v10.0 and later.
Declared in
NSText.h.NSDeleteCharacterThe delete character:
0x007fAvailable in OS X v10.0 and later.
Declared in
NSText.h.
Declared In
NSText.hNotifications
NSTextDidBeginEditingNotification
NSText object begins any operation that changes characters or formatting attributes. The notification object is the notifying NSText object. This notification does not contain a userInfo dictionary.
Availability
- Available in OS X v10.0 and later.
Declared In
NSText.hNSTextDidChangeNotification
NSText object performs any operation that changes characters or formatting attributes. The notification object is the notifying NSText object. This notification does not contain a userInfo dictionary.
Availability
- Available in OS X v10.0 and later.
Declared In
NSText.hNSTextDidEndEditingNotification
NSText object, whether or not any operation has changed characters or formatting attributes. The notification object is the notifying NSText object. The userInfo dictionary contains the following information:
Key | Value |
|---|---|
| Possible movement code values are described in “Movement Codes.” |
Availability
- Available in OS X v10.0 and later.
Declared In
NSText.h© 2010 Apple Inc. All Rights Reserved. (Last updated: 2010-03-22)